public ActionResult Delete(int?wayOfRepresentationPK) { IWaysOfRepresentationRepository waysOfRepresentationRepository = new WaysOfRepresentationRepository(db); if (wayOfRepresentationPK != null) { WayOfRepresentation wayOfRepresentation = waysOfRepresentationRepository.GetWayOfRepresentationByPK((int)wayOfRepresentationPK); wayOfRepresentation.Deleted = true; waysOfRepresentationRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", wayOfRepresentation.WayOfRepresentationPK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
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)); } }
public void ConvertTo(WayOfRepresentationView wayOfRepresentationView, WayOfRepresentation wayOfRepresentation) { wayOfRepresentation.Name = wayOfRepresentationView.Name; }
public void ConvertFrom(WayOfRepresentation wayOfRepresentation, WayOfRepresentationView wayOfRepresentationView) { wayOfRepresentationView.WayOfRepresentationPK = wayOfRepresentation.WayOfRepresentationPK; wayOfRepresentationView.Name = wayOfRepresentation.Name; wayOfRepresentationView.Deleted = wayOfRepresentation.Deleted; }