public ActionResult EditPositionDictionaryValue(PositionDictionaryValueViewModel model) { var result = new { Success = "true", Message = "Success" }; if (ModelState.IsValid) { try { var positionValue = _positionDictionaryService.GetPositionValueById(model.Id); positionValue.Name = model.Name; positionValue.Description = model.Description; positionValue.PositionDictionary.UpdatedDate = DateTime.Now; _positionDictionaryService.UpdateDictionaryValue(positionValue); } catch (Exception e) { logger.Error(e, e.Message); result = new { Success = "false", Message = WebResources.ErrorMessage }; } } else { var error = ModelState.Values.SelectMany(v => v.Errors).FirstOrDefault().ErrorMessage; result = new { Success = "false", Message = error }; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult AddPositionDictionaryValueView(int dictionaryId, int companyId) { var positionDictionaryValueViewModel = new PositionDictionaryValueViewModel() { PositionDictionaryId = dictionaryId, UserCompanyId = companyId }; return(PartialView("_AddPositionDictionaryValueViewModal", positionDictionaryValueViewModel)); }
public ActionResult AddPositionDictionaryValue(PositionDictionaryValueViewModel model) { var result = new { Success = "true", Message = "Success" }; if (ModelState.IsValid) { try { if (model.PositionDictionaryId > 0) { var positionValue = Mapper.Map <PositionDictionaryValue>(model); _positionDictionaryService.CreateDictionaryValue(positionValue); } else { PositionDictionary dictionary = new PositionDictionary() { UserCompanyId = model.UserCompanyId, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now }; int dictionaryId = _positionDictionaryService.Create(dictionary); var positionValue = Mapper.Map <PositionDictionaryValue>(model); positionValue.PositionDictionaryId = dictionaryId; _positionDictionaryService.CreateDictionaryValue(positionValue); } } catch (Exception e) { logger.Error(e, e.Message); result = new { Success = "false", Message = WebResources.ErrorMessage }; } } else { var error = ModelState.Values.SelectMany(v => v.Errors).FirstOrDefault().ErrorMessage; result = new { Success = "false", Message = error }; } return(Json(result, JsonRequestBehavior.AllowGet)); }