Esempio n. 1
0
        private Order ConvertDTOToEntity(Order_OrderDTO Order_OrderDTO)
        {
            Order Order = new Order();

            Order.Id          = Order_OrderDTO.Id;
            Order.Code        = Order_OrderDTO.Code;
            Order.OrderDate   = Order_OrderDTO.OrderDate;
            Order.PayDate     = Order_OrderDTO.PayDate;
            Order.AccountId   = Order_OrderDTO.AccountId;
            Order.NumOfTable  = Order_OrderDTO.NumOfTable;
            Order.NumOfPerson = Order_OrderDTO.NumOfPerson;
            Order.Descreption = Order_OrderDTO.Descreption;
            Order.StatusId    = Order_OrderDTO.StatusId;
            Order.Account     = Order_OrderDTO.Account == null ? null : new Account
            {
                Id                   = Order_OrderDTO.Account.Id,
                DisplayName          = Order_OrderDTO.Account.DisplayName,
                Email                = Order_OrderDTO.Account.Email,
                Phone                = Order_OrderDTO.Account.Phone,
                Password             = Order_OrderDTO.Account.Password,
                Salt                 = Order_OrderDTO.Account.Salt,
                PasswordRecoveryCode = Order_OrderDTO.Account.PasswordRecoveryCode,
                ExpiredTimeCode      = Order_OrderDTO.Account.ExpiredTimeCode,
                Address              = Order_OrderDTO.Account.Address,
                Dob                  = Order_OrderDTO.Account.Dob,
                Avatar               = Order_OrderDTO.Account.Avatar,
                RoleId               = Order_OrderDTO.Account.RoleId,
            };
            Order.BaseLanguage = CurrentContext.Language;
            return(Order);
        }
Esempio n. 2
0
        public async Task <ActionResult <Order_OrderDTO> > Get([FromBody] Order_OrderDTO Order_OrderDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            Order Order = await OrderService.Get(Order_OrderDTO.Id);

            return(new Order_OrderDTO(Order));
        }
Esempio n. 3
0
        public async Task <ActionResult <Order_OrderDTO> > Create([FromBody] Order_OrderDTO Order_OrderDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            Order Order = ConvertDTOToEntity(Order_OrderDTO);

            Order = await OrderService.Create(Order);

            Order_OrderDTO = new Order_OrderDTO(Order);
            if (Order.IsValidated)
            {
                return(Order_OrderDTO);
            }
            else
            {
                return(BadRequest(Order_OrderDTO));
            }
        }