Exemple #1
0
 public void Execute(ChnageOrderStatusDto request)
 {
     if (_context.Orders.Any(x => x.Id == request.OrderId))
     {
         var order = _context.Orders
                     .Include(p => p.OrderInfo)
                     .ThenInclude(pd => pd.Product)
                     .FirstOrDefault(x => x.Id == request.OrderId);
         if (order == null)
         {
         }
         if (order.OrderStatus == OrderStatus.Recieved)
         {
         }
         if (order.OrderStatus == OrderStatus.Recieved || order.OrderStatus == OrderStatus.Delivered)
         {
             if (request.Status == OrderStatus.Canceled || request.Status == OrderStatus.Delivered)
             {
                 order.OrderStatus = request.Status;
                 if (request.Status == OrderStatus.Canceled)
                 {
                     foreach (var n in order.OrderInfo)
                     {
                         n.Product.Quantity += n.Quantity;
                     }
                 }
                 _context.SaveChanges();
             }
         }
     }
     else
     {
         throw new EntityNotFoundException(request.OrderId, typeof(Order));
     }
 }
Exemple #2
0
 public void PromenaStatusa([FromBody] ChnageOrderStatusDto dto, [FromServices] IChangeStatusOrderCommand command)
 {
     executor.ExecuteCommand(command, dto);
 }