public TMSJobSite Add(JobSiteViewModel Vm) { var entity = _mapper.Map <JobSiteViewModel, TMSJobSite>(Vm); _iTMSJobSiteRepository.Add(entity); SaveChanges(); return(entity); }
public IActionResult Add([FromBody] JobSiteViewModel Vm) { if (!ModelState.IsValid) { var allErrors = ModelState.Values.SelectMany(v => v.Errors); return(new BadRequestObjectResult(new GenericResult(false, allErrors))); } else { try { _iTMSJobSiteService.Add(Vm); return(new OkObjectResult(new GenericResult(true, "Add success!!!"))); } catch (Exception ex) { return(new OkObjectResult(new GenericResult(false, ex.Message))); } } }