示例#1
0
        public async Task <ATZBOrder> RegisterOrderAsync(ATZBOrder order)
        {
            await _dbContext.Orders.AddAsync(order);

            await _dbContext.SaveChangesAsync();

            return(order);
        }
示例#2
0
        public async Task <IActionResult> AddOrderAsync(
            [FromBody] AddOrderBindingModel addOrderBindingModel,
            [FromHeader] string userId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(GlobalConstants.InvalidModelControllerErrorMsg));
            }

            var order = new ATZBOrder
            {
                Description  = addOrderBindingModel.Description,
                PriceTo      = addOrderBindingModel.PriceTo,
                Town         = addOrderBindingModel.Town,
                TypeForOrder = addOrderBindingModel.TypeOfOrder,
                UserId       = userId
            };

            await _orderService.RegisterOrderAsync(order);

            return(Ok());
        }