Exemple #1
0
        public async Task <DiscountDetail_DiscountDTO> Get([FromBody] DiscountDetail_DiscountDTO DiscountDetail_DiscountDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            Discount Discount = await DiscountService.Get(DiscountDetail_DiscountDTO.Id);

            return(new DiscountDetail_DiscountDTO(Discount));
        }
Exemple #2
0
        public Discount ConvertDTOToEntity(DiscountDetail_DiscountDTO DiscountDetail_DiscountDTO)
        {
            Discount Discount = new Discount();

            Discount.Id    = DiscountDetail_DiscountDTO.Id;
            Discount.Name  = DiscountDetail_DiscountDTO.Name;
            Discount.Start = DiscountDetail_DiscountDTO.Start;
            Discount.End   = DiscountDetail_DiscountDTO.End;
            Discount.Type  = DiscountDetail_DiscountDTO.Type;
            return(Discount);
        }
Exemple #3
0
        public async Task <ActionResult <DiscountDetail_DiscountDTO> > Delete([FromBody] DiscountDetail_DiscountDTO DiscountDetail_DiscountDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            Discount Discount = ConvertDTOToEntity(DiscountDetail_DiscountDTO);

            Discount = await DiscountService.Delete(Discount);

            DiscountDetail_DiscountDTO = new DiscountDetail_DiscountDTO(Discount);
            if (Discount.IsValidated)
            {
                return(DiscountDetail_DiscountDTO);
            }
            else
            {
                return(BadRequest(DiscountDetail_DiscountDTO));
            }
        }