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

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

            CustomerFeedback CustomerFeedback = ConvertDTOToEntity(CustomerFeedback_CustomerFeedbackDTO);

            CustomerFeedback = await CustomerFeedbackService.Delete(CustomerFeedback);

            CustomerFeedback_CustomerFeedbackDTO = new CustomerFeedback_CustomerFeedbackDTO(CustomerFeedback);
            if (CustomerFeedback.IsValidated)
            {
                return(CustomerFeedback_CustomerFeedbackDTO);
            }
            else
            {
                return(BadRequest(CustomerFeedback_CustomerFeedbackDTO));
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <CustomerFeedback_CustomerFeedbackDTO> > Get([FromBody] CustomerFeedback_CustomerFeedbackDTO CustomerFeedback_CustomerFeedbackDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

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

            CustomerFeedback CustomerFeedback = await CustomerFeedbackService.Get(CustomerFeedback_CustomerFeedbackDTO.Id);

            return(new CustomerFeedback_CustomerFeedbackDTO(CustomerFeedback));
        }
Ejemplo n.º 3
0
        private CustomerFeedback ConvertDTOToEntity(CustomerFeedback_CustomerFeedbackDTO CustomerFeedback_CustomerFeedbackDTO)
        {
            CustomerFeedback CustomerFeedback = new CustomerFeedback();

            CustomerFeedback.Id = CustomerFeedback_CustomerFeedbackDTO.Id;
            CustomerFeedback.IsSystemCustomer       = CustomerFeedback_CustomerFeedbackDTO.IsSystemCustomer;
            CustomerFeedback.CustomerId             = CustomerFeedback_CustomerFeedbackDTO.CustomerId;
            CustomerFeedback.FullName               = CustomerFeedback_CustomerFeedbackDTO.FullName;
            CustomerFeedback.Email                  = CustomerFeedback_CustomerFeedbackDTO.Email;
            CustomerFeedback.PhoneNumber            = CustomerFeedback_CustomerFeedbackDTO.PhoneNumber;
            CustomerFeedback.CustomerFeedbackTypeId = CustomerFeedback_CustomerFeedbackDTO.CustomerFeedbackTypeId;
            CustomerFeedback.Title                  = CustomerFeedback_CustomerFeedbackDTO.Title;
            CustomerFeedback.SendDate               = CustomerFeedback_CustomerFeedbackDTO.SendDate;
            CustomerFeedback.Content                = CustomerFeedback_CustomerFeedbackDTO.Content;
            CustomerFeedback.StatusId               = CustomerFeedback_CustomerFeedbackDTO.StatusId;
            CustomerFeedback.Customer               = CustomerFeedback_CustomerFeedbackDTO.Customer == null ? null : new Customer
            {
                Id                 = CustomerFeedback_CustomerFeedbackDTO.Customer.Id,
                Code               = CustomerFeedback_CustomerFeedbackDTO.Customer.Code,
                Name               = CustomerFeedback_CustomerFeedbackDTO.Customer.Name,
                Phone              = CustomerFeedback_CustomerFeedbackDTO.Customer.Phone,
                Address            = CustomerFeedback_CustomerFeedbackDTO.Customer.Address,
                NationId           = CustomerFeedback_CustomerFeedbackDTO.Customer.NationId,
                ProvinceId         = CustomerFeedback_CustomerFeedbackDTO.Customer.ProvinceId,
                DistrictId         = CustomerFeedback_CustomerFeedbackDTO.Customer.DistrictId,
                WardId             = CustomerFeedback_CustomerFeedbackDTO.Customer.WardId,
                CustomerTypeId     = CustomerFeedback_CustomerFeedbackDTO.Customer.CustomerTypeId,
                Birthday           = CustomerFeedback_CustomerFeedbackDTO.Customer.Birthday,
                Email              = CustomerFeedback_CustomerFeedbackDTO.Customer.Email,
                ProfessionId       = CustomerFeedback_CustomerFeedbackDTO.Customer.ProfessionId,
                CustomerResourceId = CustomerFeedback_CustomerFeedbackDTO.Customer.CustomerResourceId,
                SexId              = CustomerFeedback_CustomerFeedbackDTO.Customer.SexId,
                StatusId           = CustomerFeedback_CustomerFeedbackDTO.Customer.StatusId,
                CompanyId          = CustomerFeedback_CustomerFeedbackDTO.Customer.CompanyId,
                ParentCompanyId    = CustomerFeedback_CustomerFeedbackDTO.Customer.ParentCompanyId,
                TaxCode            = CustomerFeedback_CustomerFeedbackDTO.Customer.TaxCode,
                Fax                = CustomerFeedback_CustomerFeedbackDTO.Customer.Fax,
                Website            = CustomerFeedback_CustomerFeedbackDTO.Customer.Website,
                NumberOfEmployee   = CustomerFeedback_CustomerFeedbackDTO.Customer.NumberOfEmployee,
                BusinessTypeId     = CustomerFeedback_CustomerFeedbackDTO.Customer.BusinessTypeId,
                Investment         = CustomerFeedback_CustomerFeedbackDTO.Customer.Investment,
                RevenueAnnual      = CustomerFeedback_CustomerFeedbackDTO.Customer.RevenueAnnual,
                IsSupplier         = CustomerFeedback_CustomerFeedbackDTO.Customer.IsSupplier,
                Descreption        = CustomerFeedback_CustomerFeedbackDTO.Customer.Descreption,
                Used               = CustomerFeedback_CustomerFeedbackDTO.Customer.Used,
                RowId              = CustomerFeedback_CustomerFeedbackDTO.Customer.RowId,
            };
            CustomerFeedback.CustomerFeedbackType = CustomerFeedback_CustomerFeedbackDTO.CustomerFeedbackType == null ? null : new CustomerFeedbackType
            {
                Id   = CustomerFeedback_CustomerFeedbackDTO.CustomerFeedbackType.Id,
                Code = CustomerFeedback_CustomerFeedbackDTO.CustomerFeedbackType.Code,
                Name = CustomerFeedback_CustomerFeedbackDTO.CustomerFeedbackType.Name,
            };
            CustomerFeedback.Status = CustomerFeedback_CustomerFeedbackDTO.Status == null ? null : new Status
            {
                Id   = CustomerFeedback_CustomerFeedbackDTO.Status.Id,
                Code = CustomerFeedback_CustomerFeedbackDTO.Status.Code,
                Name = CustomerFeedback_CustomerFeedbackDTO.Status.Name,
            };
            CustomerFeedback.BaseLanguage = CurrentContext.Language;
            return(CustomerFeedback);
        }