示例#1
0
        private SupplierTypeDTO Create(SupplierTypeViewModel viewModel)
        {
            try
            {
                log.Debug(SupplierTypeViewModel.FormatSupplierTypeViewModel(viewModel));

                SupplierTypeDTO supplierType = new SupplierTypeDTO();

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

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

                // add
                log.Debug("_supplierTypeService.AddSupplierType - " + SupplierTypeDTO.FormatSupplierTypeDTO(supplierType));

                int id = _supplierTypeService.AddSupplierType(supplierType);

                supplierType.SupplierTypeId = id;

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

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

                throw;
            }
        }
示例#2
0
        public SupplierTypeDTO GetSupplierType(int supplierTypeId)
        {
            try
            {
                //Requires.NotNegative("supplierTypeId", supplierTypeId);

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

                // get
                R_SupplierType t = Repository.GetSupplierType(supplierTypeId);

                SupplierTypeDTO dto = new SupplierTypeDTO(t);

                log.Debug(SupplierTypeDTO.FormatSupplierTypeDTO(dto));

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

                throw;
            }
        }
示例#3
0
        public int AddSupplierType(SupplierTypeDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(SupplierTypeDTO.FormatSupplierTypeDTO(dto));

                R_SupplierType t = SupplierTypeDTO.ConvertDTOtoEntity(dto);

                // add
                id = Repository.AddSupplierType(t);
                dto.SupplierTypeId = id;

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

                throw;
            }

            return(id);
        }
示例#4
0
        private SupplierTypeDTO Update(SupplierTypeViewModel viewModel)
        {
            try
            {
                log.Debug(SupplierTypeViewModel.FormatSupplierTypeViewModel(viewModel));

                // get
                log.Debug("_supplierTypeService.GetSupplierType - supplierTypeId: " + viewModel.SupplierTypeId + " ");

                var existingSupplierType = _supplierTypeService.GetSupplierType(viewModel.SupplierTypeId);

                log.Debug("_supplierTypeService.GetSupplierType - " + SupplierTypeDTO.FormatSupplierTypeDTO(existingSupplierType));

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

                    // update
                    log.Debug("_supplierTypeService.UpdateSupplierType - " + SupplierTypeDTO.FormatSupplierTypeDTO(existingSupplierType));

                    _supplierTypeService.UpdateSupplierType(existingSupplierType);

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

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

                throw;
            }
        }
示例#5
0
        public void DeleteSupplierType(SupplierTypeDTO dto)
        {
            try
            {
                log.Debug(SupplierTypeDTO.FormatSupplierTypeDTO(dto));

                R_SupplierType t = SupplierTypeDTO.ConvertDTOtoEntity(dto);

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

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

                throw;
            }
        }
示例#6
0
        public void UpdateSupplierType(SupplierTypeDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "SupplierTypeId");

                log.Debug(SupplierTypeDTO.FormatSupplierTypeDTO(dto));

                R_SupplierType t = SupplierTypeDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateSupplierType(t);

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

                throw;
            }
        }