Пример #1
0
        // GET CREATE CEMETERY
        public ViewResult Create(int ClientID)
        {
            // create view model
            var viewModel = new CemeteryFormViewModel
            {
                ClientId = ClientID
            };

            return View("Edit", viewModel);
        }
Пример #2
0
        public ActionResult Edit(CemeteryFormViewModel cemeteryForm)
        {
            var cemetery = Mapper.Map<CemeteryFormViewModel, Cemetery>(cemeteryForm);
            var client = clientsRepository.GetClient(cemeteryForm.ClientId);

            if (ModelState.IsValid)
            {
                clientsRepository.SaveCemetery(cemetery);
                client.CemeteryId = cemetery.CemeteryID;
                clientsRepository.SaveClient(client);
                TempData["message"] = "Cemetery: " + cemetery.CemeteryName + " has been saved.";
                return RedirectToAction("List", "LegalFinance", new { cemeteryForm.ClientId });
            }
            else // validation error, so redisplay the same view
            {
                return View("Edit", cemeteryForm);
            }
        }