Exemple #1
0
        public async Task <ActionResult <CustomerGrouping_CustomerGroupingDTO> > Delete([FromBody] CustomerGrouping_CustomerGroupingDTO CustomerGrouping_CustomerGroupingDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(CustomerGrouping_CustomerGroupingDTO.Id))
            {
                return(Forbid());
            }

            CustomerGrouping CustomerGrouping = ConvertDTOToEntity(CustomerGrouping_CustomerGroupingDTO);

            CustomerGrouping = await CustomerGroupingService.Delete(CustomerGrouping);

            CustomerGrouping_CustomerGroupingDTO = new CustomerGrouping_CustomerGroupingDTO(CustomerGrouping);
            if (CustomerGrouping.IsValidated)
            {
                return(CustomerGrouping_CustomerGroupingDTO);
            }
            else
            {
                return(BadRequest(CustomerGrouping_CustomerGroupingDTO));
            }
        }
Exemple #2
0
        public async Task <ActionResult <CustomerGrouping_CustomerGroupingDTO> > Get([FromBody] CustomerGrouping_CustomerGroupingDTO CustomerGrouping_CustomerGroupingDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(CustomerGrouping_CustomerGroupingDTO.Id))
            {
                return(Forbid());
            }

            CustomerGrouping CustomerGrouping = await CustomerGroupingService.Get(CustomerGrouping_CustomerGroupingDTO.Id);

            return(new CustomerGrouping_CustomerGroupingDTO(CustomerGrouping));
        }
Exemple #3
0
        private CustomerGrouping ConvertDTOToEntity(CustomerGrouping_CustomerGroupingDTO CustomerGrouping_CustomerGroupingDTO)
        {
            CustomerGrouping CustomerGrouping = new CustomerGrouping();

            CustomerGrouping.Id             = CustomerGrouping_CustomerGroupingDTO.Id;
            CustomerGrouping.Code           = CustomerGrouping_CustomerGroupingDTO.Code;
            CustomerGrouping.Name           = CustomerGrouping_CustomerGroupingDTO.Name;
            CustomerGrouping.CustomerTypeId = CustomerGrouping_CustomerGroupingDTO.CustomerTypeId;
            CustomerGrouping.ParentId       = CustomerGrouping_CustomerGroupingDTO.ParentId;
            CustomerGrouping.Path           = CustomerGrouping_CustomerGroupingDTO.Path;
            CustomerGrouping.Level          = CustomerGrouping_CustomerGroupingDTO.Level;
            CustomerGrouping.StatusId       = CustomerGrouping_CustomerGroupingDTO.StatusId;
            CustomerGrouping.Description    = CustomerGrouping_CustomerGroupingDTO.Description;
            CustomerGrouping.CustomerType   = CustomerGrouping_CustomerGroupingDTO.CustomerType == null ? null : new CustomerType
            {
                Id   = CustomerGrouping_CustomerGroupingDTO.CustomerType.Id,
                Code = CustomerGrouping_CustomerGroupingDTO.CustomerType.Code,
                Name = CustomerGrouping_CustomerGroupingDTO.CustomerType.Name,
            };
            CustomerGrouping.Parent = CustomerGrouping_CustomerGroupingDTO.Parent == null ? null : new CustomerGrouping
            {
                Id             = CustomerGrouping_CustomerGroupingDTO.Parent.Id,
                Code           = CustomerGrouping_CustomerGroupingDTO.Parent.Code,
                Name           = CustomerGrouping_CustomerGroupingDTO.Parent.Name,
                CustomerTypeId = CustomerGrouping_CustomerGroupingDTO.Parent.CustomerTypeId,
                ParentId       = CustomerGrouping_CustomerGroupingDTO.Parent.ParentId,
                Path           = CustomerGrouping_CustomerGroupingDTO.Parent.Path,
                Level          = CustomerGrouping_CustomerGroupingDTO.Parent.Level,
                StatusId       = CustomerGrouping_CustomerGroupingDTO.Parent.StatusId,
                Description    = CustomerGrouping_CustomerGroupingDTO.Parent.Description,
            };
            CustomerGrouping.Status = CustomerGrouping_CustomerGroupingDTO.Status == null ? null : new Status
            {
                Id   = CustomerGrouping_CustomerGroupingDTO.Status.Id,
                Code = CustomerGrouping_CustomerGroupingDTO.Status.Code,
                Name = CustomerGrouping_CustomerGroupingDTO.Status.Name,
            };
            CustomerGrouping.BaseLanguage = CurrentContext.Language;
            return(CustomerGrouping);
        }