public ActionResult Details(int id) { Telephone telephone = _repository.Get(id); var toDisplay = new TelephoneViewModel { Id = telephone.Id, CustomerId = telephone.CustomerId, PhoneNumber = telephone.PhoneNumber, IsPrimary = telephone.IsPrimary, ModifiedDate = telephone.ModifiedDate }; return toDisplay.Id > 0 ? View(toDisplay) : View("No data found"); }
public ActionResult Create(int customerId, Telephone telephone) { try { _repository.Add(customerId, telephone); var telephoneToDisplay = new TelephoneViewModel { CustomerId = customerId, Id = telephone.Id, PhoneNumber = telephone.PhoneNumber, IsPrimary = telephone.IsPrimary, ModifiedDate = telephone.ModifiedDate }; return RedirectToAction("Index", telephoneToDisplay); } catch { return View(); } }
public ActionResult Edit(int id) { Telephone telephone = _repository.Get(id); var custToDisplay = new TelephoneViewModel { Id = telephone.Id, CustomerId = telephone.CustomerId, PhoneNumber = telephone.PhoneNumber, IsPrimary = telephone.IsPrimary, ModifiedDate = telephone.ModifiedDate }; return View(custToDisplay); }