public ActionResult EditJobPartDictionaryValue(JobPartDictionaryValueViewModel model) { var result = new { Success = "true", Message = "Success" }; if (ModelState.IsValid) { try { var positionValue = _jobPartDictionaryService.GetJobPartValueById(model.Id); positionValue.Name = model.Name; positionValue.Notes = model.Notes; positionValue.JobPartDictionary.UpdatedDate = DateTime.Now; _jobPartDictionaryService.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 AddJobPartDictionaryValueView(int dictionaryId, int companyId) { var jobPartDictionaryValueViewModel = new JobPartDictionaryValueViewModel() { JobPartDictionaryId = dictionaryId, UserCompanyId = companyId }; return(PartialView("_AddJobPartDictionaryValueViewModal", jobPartDictionaryValueViewModel)); }
public ActionResult AddJobPartDictionaryValue(JobPartDictionaryValueViewModel model) { var result = new { Success = "true", Message = "Success" }; if (ModelState.IsValid) { try { if (model.JobPartDictionaryId > 0) { var jobPartValue = Mapper.Map <JobPartDictionaryValue>(model); _jobPartDictionaryService.CreateDictionaryValue(jobPartValue); } else { JobPartDictionary dictionary = new JobPartDictionary() { UserCompanyId = model.UserCompanyId, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now }; int dictionaryId = _jobPartDictionaryService.Create(dictionary); var positionValue = Mapper.Map <JobPartDictionaryValue>(model); positionValue.JobPartDictionaryId = dictionaryId; _jobPartDictionaryService.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)); }