public JsonResult Edit(EducationalUnitsViewModel model) { if (ModelState.IsValid) { var EducationalUnitsEntity = _enterpriseUnitService.GetById(model.Id); EducationalUnitsEntity = Mapper.Map(model, EducationalUnitsEntity); _enterpriseUnitService.Edit(EducationalUnitsEntity); return(Json(new { data = model, success = true }, JsonRequestBehavior.AllowGet)); } var errors = ModelState.GetDistinctModelErrors(); return(Json(new { data = model, success = false, ErrorsList = errors }, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(decimal?ParentId) { ViewBag.Title = Resources.PageTitle.UserCategory_Add; ViewBag.PageBar = GetPageBar(Resources.PageTitle.EducationalUnits_Add); ViewBag.Description = ""; var model = new EducationalUnitsViewModel(); if (ParentId.HasValue) { model.Parent = ParentId; model.ParentName = _enterpriseUnitService.GetById(ParentId).Name; } return(View(model)); }
public JsonResult Add(EducationalUnitsViewModel model) { if (ModelState.IsValid) { var EntityMapped = Mapper.Map <EnterpriseUnit>(model); EntityMapped.Level1Id = CurrentUser.LevelResponsibleForMe.Level1Id; EntityMapped.Level2Id = CurrentUser.LevelResponsibleForMe.Level2Id; EntityMapped.Level3Id = CurrentUser.LevelResponsibleForMe.Level3Id; EntityMapped.Level4Id = CurrentUser.LevelResponsibleForMe.Level4Id; EntityMapped.EnterpriseUnitsType = (int)EnterpriseUnitsTypeEnum.Educational; EntityMapped.CreatedDate = DateTime.Now; EntityMapped.CreatedById = CurrentUser.Id; _enterpriseUnitService.Add(EntityMapped); return(Json(new { data = model, success = true }, JsonRequestBehavior.AllowGet)); } var errors = ModelState.GetDistinctModelErrors(); return(Json(new { data = model, success = false, ErrorsList = errors }, JsonRequestBehavior.AllowGet)); }