public async Task <JsonResult> Update(JobtitleViewModel vm) { try { var model = JobTitleUtility.VMToM(vm); _jobTitleService.Update(model); return(Json(new { success = true, data = vm })); } catch { return(Json(new { success = false })); } }
public static JobTitle VMToM(JobtitleViewModel model) { return(new JobTitle() { ID = model.ID, Description = model.Description, CompanyID = model.Company.ID, DepartmentID = model.Department.ID }); }
//jobtitle public static JobtitleViewModel MToVM(JobTitle model) { var temp = new JobtitleViewModel() { ID = model.ID, Description = model.Description, Department = new DepartmentViewModel() { ID = model.DepartmentID } }; return(temp); }
public async Task <JsonResult> Insert(JobtitleViewModel vm) { try { vm.ID = CharacterGenerator.NewGUID(); vm.Company = new CompanyViewModel() { ID = CurrentUser.CompanyID }; var model = JobTitleUtility.VMToM(vm); _jobTitleService.Insert(model); var list = _jobTitleService.GetAll().Result.ToList(); list = JobTitleUtility.FilterByCompanyID(list, CurrentUser.CompanyID); return(Json(new { success = true, data = JobTitleUtility.MToVM(model) })); } catch { return(Json(new { success = false })); } }