Created
December 2, 2015 22:19
-
-
Save samueleresca/6103db95b57d3630ad37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.Mvc; | |
using Blog.QueryingMongoDb.Models; | |
using Blog.QueryingMongoDb.Models.Repository; | |
namespace Blog.QueryingMongoDb.Controllers | |
{ | |
public class ContactController : Controller | |
{ | |
//Private instance of contact collection | |
private ContactCollection _contacts = new ContactCollection(); | |
// | |
// GET: /ContactUs/ | |
public ActionResult Create() | |
{ | |
return View(); | |
} | |
[HttpPost] | |
public ActionResult Create(ContactModel contact) | |
{ | |
this._contacts.InsertContact(contact); | |
return RedirectToAction("List", _contacts.SelectAll()); | |
} | |
public ActionResult List() | |
{ | |
return View( | |
_contacts.SelectAll()); | |
} | |
public ActionResult Edit(string contactId) | |
{ | |
return View(_contacts.Get(contactId)); | |
} | |
[HttpPost] | |
public ActionResult Edit(string Id, ContactModel contact) | |
{ | |
this._contacts.UpdateContact(Id, contact); | |
return RedirectToAction("List", | |
_contacts.SelectAll()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment