public ActionResult Insert() { var model = new PostCardViewModel(); model.Operation = "I"; return(View("InsertEdit", model)); }
public virtual ActionResult PostCardViewPartialView(PostCardViewModel model, ViewStyles style = ViewStyles.Large) { switch (style) { case ViewStyles.Large: return(View("Partials/_PostLargeCardView", model)); case ViewStyles.Normal: return(View("Partials/_PostNormalCardView", model)); case ViewStyles.Small: return(View("Partials/_PostSmallCardView", model)); default: throw new ArgumentOutOfRangeException(nameof(style), style, null); } }
public ActionResult InsertEdit(PostCardViewModel model) { if (!ModelState.IsValid) { TempData["Error"] = "Transaction error"; return(RedirectToAction("Index", "Sectors")); } var entity = _mapper.Map <PostCardViewModel, PostCardEntity>(model); entity.ImagePath = Server.MapPath("~/Content/img/Uploads/"); var result = model.Operation == "E" ? _postCardsManager.Update(entity) : _postCardsManager.Insert(entity); TempData["Result"] = result; if (!result.Success) { return(RedirectToAction("Index")); } var operation = model.Operation == "E" ? "Edit Postcard" : "Insert Postcard"; StoreLog("Postcards", operation, (int)result.Entity); return(RedirectToAction("Edit", new { id = (int)result.Entity })); }