예제 #1
0
        public SupplierDTO GetSupplier(int supplierId)
        {
            try
            {
                //Requires.NotNegative("supplierId", supplierId);

                log.Debug("supplierId: " + supplierId + " ");

                // get
                R_Supplier t = Repository.GetSupplier(supplierId);

                SupplierDTO dto = new SupplierDTO(t);

                log.Debug(SupplierDTO.FormatSupplierDTO(dto));

                return(dto);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
예제 #2
0
        public int AddSupplier(SupplierDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(SupplierDTO.FormatSupplierDTO(dto));

                R_Supplier t = SupplierDTO.ConvertDTOtoEntity(dto);

                // add
                id             = Repository.AddSupplier(t);
                dto.SupplierId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
예제 #3
0
        private SupplierDTO Create(SupplierViewModel viewModel)
        {
            try
            {
                log.Debug(SupplierViewModel.FormatSupplierViewModel(viewModel));

                SupplierDTO supplier = new SupplierDTO();

                // copy values
                viewModel.UpdateDTO(supplier, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                supplier.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                supplier.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_supplierService.AddSupplier - " + SupplierDTO.FormatSupplierDTO(supplier));

                int id = _supplierService.AddSupplier(supplier);

                supplier.SupplierId = id;

                log.Debug("result: 'success', id: " + id);

                return(supplier);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
예제 #4
0
        private SupplierDTO Update(SupplierViewModel viewModel)
        {
            try
            {
                log.Debug(SupplierViewModel.FormatSupplierViewModel(viewModel));

                // get
                log.Debug("_supplierService.GetSupplier - supplierId: " + viewModel.SupplierId + " ");

                var existingSupplier = _supplierService.GetSupplier(viewModel.SupplierId);

                log.Debug("_supplierService.GetSupplier - " + SupplierDTO.FormatSupplierDTO(existingSupplier));

                if (existingSupplier != null)
                {
                    // copy values
                    viewModel.UpdateDTO(existingSupplier, null); //RequestContext.Principal.Identity.GetUserId());

                    // update
                    log.Debug("_supplierService.UpdateSupplier - " + SupplierDTO.FormatSupplierDTO(existingSupplier));

                    _supplierService.UpdateSupplier(existingSupplier);

                    log.Debug("result: 'success'");
                }
                else
                {
                    log.Error("existingSupplier: null, SupplierId: " + viewModel.SupplierId);
                }

                return(existingSupplier);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
예제 #5
0
        public void DeleteSupplier(SupplierDTO dto)
        {
            try
            {
                log.Debug(SupplierDTO.FormatSupplierDTO(dto));

                R_Supplier t = SupplierDTO.ConvertDTOtoEntity(dto);

                // delete
                Repository.DeleteSupplier(t);
                dto.IsDeleted = t.IsDeleted;

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
예제 #6
0
        public void UpdateSupplier(SupplierDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "SupplierId");

                log.Debug(SupplierDTO.FormatSupplierDTO(dto));

                R_Supplier t = SupplierDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateSupplier(t);

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }