Advertisement
Guest User

Untitled

a guest
Feb 18th, 2015
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using Storage_test.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7.  
  8. namespace Storage_test.Controllers
  9. {
  10. public class StorageController : Controller
  11. {
  12. private StorageRecordContext _db = new StorageRecordContext();
  13.  
  14. public ActionResult Create() {
  15. return View();
  16. }
  17.  
  18. [HttpPost]
  19. public ActionResult Create(StorageRecord record){
  20. _db.TheRecords.Add(record);
  21. _db.SaveChanges();
  22. return RedirectToAction("Index");
  23. }
  24.  
  25.  
  26. //
  27. // GET: /Storage/
  28.  
  29. public ActionResult Index()
  30. {
  31. var mostRecentRecord = (from record in _db.TheRecords select record).Take(20);
  32. ViewBag.allRecords = mostRecentRecord.ToList();
  33. return View();
  34.  
  35. }
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement