public ActionResult Edit(int?wayOfRepresentationPK) { if (wayOfRepresentationPK != null) { IWaysOfRepresentationRepository waysOfRepresentationRepository = new WaysOfRepresentationRepository(db); WayOfRepresentation wayOfRepresentation = waysOfRepresentationRepository.GetWayOfRepresentationByPK((int)wayOfRepresentationPK); WayOfRepresentationView wayOfRepresentationView = new WayOfRepresentationView(); wayOfRepresentationView.ConvertFrom(wayOfRepresentation, wayOfRepresentationView); return(View(wayOfRepresentationView)); } else { return(RedirectToAction("Index", "WayOfRepresentation")); } }
public ActionResult Edit(WayOfRepresentationView wayOfRepresentationModel) { if (ModelState.IsValid) { IWaysOfRepresentationRepository waysOfRepresentationRepository = new WaysOfRepresentationRepository(db); WayOfRepresentation wayOfRepresentation = waysOfRepresentationRepository.GetWayOfRepresentationByPK((int)wayOfRepresentationModel.WayOfRepresentationPK); wayOfRepresentationModel.ConvertTo(wayOfRepresentationModel, wayOfRepresentation); waysOfRepresentationRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", wayOfRepresentation.WayOfRepresentationPK); return(RedirectToAction("Index", "WayOfRepresentation")); } else { return(View(wayOfRepresentationModel)); } }
public ActionResult Add(WayOfRepresentationView wayOfRepresentationView) { if (ModelState.IsValid) { IWaysOfRepresentationRepository waysOfRepresentationRepository = new WaysOfRepresentationRepository(db); WayOfRepresentation wayOfRepresentation = new WayOfRepresentation(); wayOfRepresentationView.ConvertTo(wayOfRepresentationView, wayOfRepresentation); waysOfRepresentationRepository.Add(wayOfRepresentation); waysOfRepresentationRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", wayOfRepresentation.WayOfRepresentationPK); return(RedirectToAction("Index", "WayOfRepresentation")); } else { return(View(wayOfRepresentationView)); } }