PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/RavenDb-Stockholm/Controllers/Brute.cs

https://github.com/ivarszarins/ravendb-stockholm
C# | 50 lines | 45 code | 5 blank | 0 comment | 0 complexity | dd58468b7aa16a64dddc3b1e79c8b19f MD5 | raw file
  1. using System;
  2. using System.IO;
  3. using System.IO.Pipes;
  4. using System.Net;
  5. using System.Runtime.Serialization.Formatters;
  6. using System.Web.Mvc;
  7. using Raven.Json.Linq;
  8. using RavenDb_Stockholm.Indexes;
  9. using RavenDb_Stockholm.Models;
  10. using Raven.Client.Linq;
  11. using System.Linq;
  12. namespace RavenDb_Stockholm.Controllers
  13. {
  14. public class BruteController : RavenController
  15. {
  16. public ActionResult Upload()
  17. {
  18. var downloadData = new WebClient().DownloadData("https://www.google.com/images/srpr/logo3w.png");
  19. Store.DatabaseCommands.PutAttachment("logo.png", null,
  20. new MemoryStream(downloadData), new RavenJObject
  21. {
  22. {"Content-Type", "image/png"}
  23. });
  24. return Content("OK");
  25. }
  26. public ActionResult Search(string name)
  27. {
  28. var results = Session.Query<People_Search.Result, People_Search>()
  29. .Search(x => x.Name, name)
  30. .OrderBy(x=>x.Name)
  31. .As<object>()
  32. .ToList();
  33. return Json(results);
  34. }
  35. public ActionResult Force(string name)
  36. {
  37. Session.Store(new Instructor
  38. {
  39. Name = name,
  40. Id = "instructors/1235"
  41. });
  42. return Content("OK");
  43. }
  44. }
  45. }