コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
        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;
            }
        }