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

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

            CustomerLevel CustomerLevel = ConvertDTOToEntity(CustomerLevel_CustomerLevelDTO);

            CustomerLevel = await CustomerLevelService.Delete(CustomerLevel);

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

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

            CustomerLevel CustomerLevel = await CustomerLevelService.Get(CustomerLevel_CustomerLevelDTO.Id);

            return(new CustomerLevel_CustomerLevelDTO(CustomerLevel));
        }
示例#3
0
        private CustomerLevel ConvertDTOToEntity(CustomerLevel_CustomerLevelDTO CustomerLevel_CustomerLevelDTO)
        {
            CustomerLevel CustomerLevel = new CustomerLevel();

            CustomerLevel.Id          = CustomerLevel_CustomerLevelDTO.Id;
            CustomerLevel.Code        = CustomerLevel_CustomerLevelDTO.Code;
            CustomerLevel.Name        = CustomerLevel_CustomerLevelDTO.Name;
            CustomerLevel.Color       = CustomerLevel_CustomerLevelDTO.Color;
            CustomerLevel.PointFrom   = CustomerLevel_CustomerLevelDTO.PointFrom;
            CustomerLevel.PointTo     = CustomerLevel_CustomerLevelDTO.PointTo;
            CustomerLevel.StatusId    = CustomerLevel_CustomerLevelDTO.StatusId;
            CustomerLevel.Description = CustomerLevel_CustomerLevelDTO.Description;
            CustomerLevel.Used        = CustomerLevel_CustomerLevelDTO.Used;
            CustomerLevel.RowId       = CustomerLevel_CustomerLevelDTO.RowId;
            CustomerLevel.Status      = CustomerLevel_CustomerLevelDTO.Status == null ? null : new Status
            {
                Id   = CustomerLevel_CustomerLevelDTO.Status.Id,
                Code = CustomerLevel_CustomerLevelDTO.Status.Code,
                Name = CustomerLevel_CustomerLevelDTO.Status.Name,
            };
            CustomerLevel.BaseLanguage = CurrentContext.Language;
            return(CustomerLevel);
        }