Пример #1
0
 public void SetState(OrderStateDto orderStateDto)
 {
     using (NpgsqlConnection connection = this.databaseConnectionFactory.Instance.Create())
     {
         OrderState orderState = this.dtoToEntityMapper.Map <OrderStateDto, OrderState>(orderStateDto);
         this.orderService.UpdateState(connection, orderState);
     }
 }
        public HttpResponseMessage SetState(OrderStateModel orderStateModel)
        {
            OrderStateDto orderStateDto = this.mapper.Map <OrderStateModel, OrderStateDto>(orderStateModel);

            this.orderAppService.SetState(orderStateDto);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Пример #3
0
        public List <OrderDto> GetOrdersByState(OrderStateDto state)
        {
            using (var db = new CourierHelperDb(_connectionString))
            {
                List <Order> orders = db.OrdersRepo.Query.Where(o => o.State == (OrderState)state).ToList();

                List <OrderDto> ordersDto = Mapper.Map <List <OrderDto> >(orders);

                return(ordersDto);
            }
        }
Пример #4
0
        public async Task ChangeOrderStateAsync(OrderDto orderDto, OrderStateDto state)
        {
            using (var db = new CourierHelperDb(_connectionString))
            {
                Order order = db.OrdersRepo.Get(orderDto.Id);

                if (order == null)
                {
                    throw new ArgumentOutOfRangeException($"The order with id {orderDto.Id} does not exist!");
                }

                order.State = (OrderState)state;

                db.OrdersRepo.Update(order);
                await db.SaveAsync();

                orderDto.State = state;
            }
        }
Пример #5
0
        public ActionResult UpdateOrderState(OrderStateDto orderState)
        {
            var result = _orderService.UpdateOrderState(orderState);

            return(Json(result));
        }
        public IHttpActionResult GetOrderByState(OrderStateDto state)
        {
            List <OrderDto> ordersDto = OrderService.GetOrdersByState(state);

            return(Ok(ordersDto));
        }