public ActionResult Add(ASMViewModel model) { AlertMessage alert = new AlertMessage(); ASMBusiness business = new ASMBusiness(); if (!ModelState.IsValid) { alert.Text = string.Join(System.Environment.NewLine, ModelState.Values .SelectMany(v => v.Errors) .Select(e => e.ErrorMessage)); } else { business.SetUserAuth(ViewBag.UserAuth); alert = business.Add(model); } TempData["AlertMessage"] = alert; if (alert.Status == 1) { return(RedirectToAction("Index")); } ViewBag.ListRayonType = business.GetListRayonType(); return(View("Edit", model)); }
public ActionResult Add() { ASMBusiness business = new ASMBusiness(); ViewBag.ListRayonType = business.GetListRayonType(); return(View("Edit", new ASMViewModel())); }
public ActionResult Edit(int?id = null) { ViewBag.IsEdit = true; if (id == null) { return(RedirectToAction("Index")); } ASMBusiness business = new ASMBusiness(); ASMViewModel model = business.GetDetail(id.Value); if (model == null) { TempData["AlertMessage"] = new AlertMessage(StaticMessage.ERR_DATA_NOT_FOUND); return(RedirectToAction("Index")); } ViewBag.ListRayonType = business.GetListRayonType(); return(View(model)); }