public async Task <ActionResult> AddSampleData() { MyContactsRepository repo = new MyContactsRepository(); await repo.AddSampleData(); return(Redirect("/Contacts")); }
public async Task <ActionResult> DeleteAllContacts() { MyContactsRepository repo = new MyContactsRepository(); await repo.DeleteAllContacts(); return(Redirect("/Contacts")); }
public async Task <ActionResult> Delete(string id) { MyContactsRepository repository = new MyContactsRepository(); if (id != null) { await repository.DeleteContact(id); } return(Redirect("/")); }
public async Task <ActionResult> Details(string id) { ExchangeClientDemo.Models.MyContact contact = null; try { MyContactsRepository repo = new MyContactsRepository(); contact = await repo.GetContact(id); } catch (RedirectRequiredException x) { return(Redirect(x.RedirectUri.ToString())); } return(View(contact)); }
public async Task <ActionResult> Create(MyContact myContact) { if (Request.HttpMethod == "POST") { MyContactsRepository repository = new MyContactsRepository(); await repository.AddContact(myContact); return(Redirect("/")); } else { return(View(myContact)); } }
public async Task <ActionResult> Create(ExchangeClientDemo.Models.MyContact contact) { if (Request.HttpMethod == "POST") { MyContactsRepository repo = new MyContactsRepository(); await repo.AddContact(contact); return(Redirect("/Contacts")); } else { return(View(contact)); } }
public async Task <ActionResult> Edit(string Id, ExchangeClientDemo.Models.MyContact contact) { MyContactsRepository repo = new MyContactsRepository(); if (Request.HttpMethod == "POST") { await repo.UpdateContact(contact); return(Redirect("/Contacts")); } else { contact = await repo.GetContact(Id); return(View(contact)); } }
public async Task <ActionResult> Index(int?pageNumber) { int pageSize = 8; int pageIndex = (pageNumber != null) ? (int)pageNumber - 1 : 0; ViewBag.pageIndex = pageIndex; ViewBag.pageSize = pageSize; List <MyContact> contacts = null; try { MyContactsRepository repository = new MyContactsRepository(); ViewBag.contactCount = await repository.GetContactCount(); contacts = await repository.GetContacts(pageIndex, pageSize); } catch (RedirectRequiredException x) { return(Redirect(x.RedirectUri.ToString())); } return(View(contacts)); }