public LPCReportModel UpdateLPCReport(LPCReportModel model) { var report = _lpcReportRepository.GetSingle(model.Id); Mapper.Map(model, report); _lpcReportRepository.Edit(report); _lpcReportRepository.Commit(); var results = _lpcReportRepository.GetSingle(model.Id); return(Mapper.Map <LPCReport, LPCReportModel>(results)); }
public void Put_Sucess_Update_Record() { var controller = PrepareController(); var id = 11; var model = new LPCReportModel { }; var actionResult = controller.Put(id, model); // Assert actionResult.Should().BeOfType <OkResult>(); }
public void Put_Exception_Return_NoContent() { var controller = PrepareController(); var id = 110; var dbContext = serviceProvider.GetRequiredService <NYCLandmarkContext>(); var model1 = dbContext.LPCReports.Where(x => x.Id == 1); var model = new LPCReportModel { }; var actionResult = controller.Put(id, model); // Assert actionResult.Should().BeOfType <NoContentResult>(); }
public IActionResult Put(int id, [FromBody] LPCReportModel model) { var validator = new LPCReportRule(); var validationResults = validator.Validate(model); if (!validationResults.IsValid) { return(Json(validationResults.Errors)); } var result = _lpcReportService.GetLPCReport(id); if (result == null) { return(NotFound()); } _lpcReportService.UpdateLPCReport(model); return(new NoContentResult()); }