public IActionResult Update([FromBody] TMSAllowanceJobsiteViewModel Vm) { if (!ModelState.IsValid) { var allErrors = ModelState.Values.SelectMany(v => v.Errors); return(new BadRequestObjectResult(new GenericResult(false, allErrors))); } else { try { if (Vm.StartDate == null) { Vm.StartDate = new DateTime(0001, 01, 01, 00, 00, 00); } if (Vm.EndDate == null) { Vm.EndDate = new DateTime(0001, 01, 01, 00, 00, 00); } _tmsAllowanceJobsiteService.Update(Vm); return(new OkObjectResult(new GenericResult(true, "Update Success"))); } catch (Exception ex) { return(new OkObjectResult(new GenericResult(false, ex.Message))); } } }
public void Update(TMSAllowanceJobsiteViewModel Vm) { var data = _mapper.Map <TMSAllowanceJobsiteViewModel, TMSAllowanceJobsite>(Vm); _tmsAllowanceJobsiteRepository.Update(data); SaveChanges(); }