private DeliveryReportDTO Create(DeliveryReportViewModel viewModel) { try { log.Debug(DeliveryReportViewModel.FormatDeliveryReportViewModel(viewModel)); DeliveryReportDTO deliveryReport = new DeliveryReportDTO(); // copy values viewModel.UpdateDTO(deliveryReport, null); //RequestContext.Principal.Identity.GetUserId()); // audit deliveryReport.CreateBy = null; //RequestContext.Principal.Identity.GetUserId(); deliveryReport.CreateOn = DateTime.UtcNow; // add log.Debug("_deliveryReportService.AddDeliveryReport - " + DeliveryReportDTO.FormatDeliveryReportDTO(deliveryReport)); int id = _deliveryReportService.AddDeliveryReport(deliveryReport); deliveryReport.DeliveryReportId = id; log.Debug("result: 'success', id: " + id); return(deliveryReport); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }
public DeliveryReportDTO GetDeliveryReport(int deliveryReportId) { try { //Requires.NotNegative("deliveryReportId", deliveryReportId); log.Debug("deliveryReportId: " + deliveryReportId + " "); // get R_DeliveryReport t = Repository.GetDeliveryReport(deliveryReportId); DeliveryReportDTO dto = new DeliveryReportDTO(t); log.Debug(DeliveryReportDTO.FormatDeliveryReportDTO(dto)); return(dto); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public int AddDeliveryReport(DeliveryReportDTO dto) { int id = 0; try { log.Debug(DeliveryReportDTO.FormatDeliveryReportDTO(dto)); R_DeliveryReport t = DeliveryReportDTO.ConvertDTOtoEntity(dto); // add id = Repository.AddDeliveryReport(t); dto.DeliveryReportId = id; log.Debug("result: 'success', id: " + id); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } return(id); }
private DeliveryReportDTO Update(DeliveryReportViewModel viewModel) { try { log.Debug(DeliveryReportViewModel.FormatDeliveryReportViewModel(viewModel)); // get log.Debug("_deliveryReportService.GetDeliveryReport - deliveryReportId: " + viewModel.DeliveryReportId + " "); var existingDeliveryReport = _deliveryReportService.GetDeliveryReport(viewModel.DeliveryReportId); log.Debug("_deliveryReportService.GetDeliveryReport - " + DeliveryReportDTO.FormatDeliveryReportDTO(existingDeliveryReport)); if (existingDeliveryReport != null) { // copy values viewModel.UpdateDTO(existingDeliveryReport, null); //RequestContext.Principal.Identity.GetUserId()); // update log.Debug("_deliveryReportService.UpdateDeliveryReport - " + DeliveryReportDTO.FormatDeliveryReportDTO(existingDeliveryReport)); _deliveryReportService.UpdateDeliveryReport(existingDeliveryReport); log.Debug("result: 'success'"); } else { log.Error("existingDeliveryReport: null, DeliveryReportId: " + viewModel.DeliveryReportId); } return(existingDeliveryReport); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }
public void DeleteDeliveryReport(DeliveryReportDTO dto) { try { log.Debug(DeliveryReportDTO.FormatDeliveryReportDTO(dto)); R_DeliveryReport t = DeliveryReportDTO.ConvertDTOtoEntity(dto); // delete Repository.DeleteDeliveryReport(t); dto.IsDeleted = t.IsDeleted; log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void UpdateDeliveryReport(DeliveryReportDTO dto) { try { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "DeliveryReportId"); log.Debug(DeliveryReportDTO.FormatDeliveryReportDTO(dto)); R_DeliveryReport t = DeliveryReportDTO.ConvertDTOtoEntity(dto); // update Repository.UpdateDeliveryReport(t); log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }