Exemplo n.º 1
0
        //return open order from order of user this will use for return open order
        public Order GetOrder(string username, int?orderId = null, bool withIncludes = false)
        {
            OrderStatusTypes   status = OrderStatusTypes.Open;
            Order              order  = null;
            IQueryable <Order> orders = db.Orders.Where(x => x.Customer.UserName == username && x.OrderStatus == status);

            if (orderId.HasValue)
            {
                orders = orders.Where(x => x.Id == orderId.Value);
            }
            if (withIncludes)
            {
                orders = orders.Include(x => x.OrderDetails)
                         .ThenInclude(x => x.Product);
            }
            var ordersList = orders.ToList();

            switch (ordersList.Count())
            {
            case 0:
                return(order);

            case 1:
                return(orders.SingleOrDefault());

            default:
                foreach (var item in orders)
                {
                    item.OrderStatus = OrderStatusTypes.NeedReview;
                }
                db.SaveChanges();
                return(order);
            }
        }
Exemplo n.º 2
0
 public ResponsViewModel UpdateOrderStatus(int?id, OrderStatusTypes orderStatus)
 {
     if (id == null)
     {
         return(new ResponsViewModel()
         {
             Message = "Invalid Order",
             Succeed = false
         });
     }
     try
     {
         db.Orders.Where(x => x.Id == id).SingleOrDefault().OrderStatus = orderStatus;
         db.SaveChanges();
     }
     catch
     {
         return(new ResponsViewModel()
         {
             Message = "something wrong",
             Succeed = false
         });
     }
     return(new ResponsViewModel()
     {
         Message = "Order Updated",
         Succeed = true
     });
 }
Exemplo n.º 3
0
 public OrderStatusHistory(IDataRecord row)
 {
     this.Date              = Convert.ToDateTime(row["date"]);
     this.DateAsString      = row["date"].ToString();
     this.OrderStatusTypeId = int.Parse(row["order_status_type_id"].ToString());
     this.OrderStatusType   = (OrderStatusTypes)this.OrderStatusTypeId;
 }
Exemplo n.º 4
0
 public OrderStatusHistory(DateTime date, int orderStatusTypeId)
 {
     this.Date              = date;
     this.DateAsString      = date.ToShortDateString();
     this.OrderStatusTypeId = orderStatusTypeId;
     this.OrderStatusType   = (OrderStatusTypes)orderStatusTypeId;
 }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, OrderStatusTypes orderStatus)
        {
            EditOrderAdminViewModel respons = new EditOrderAdminViewModel();
            Order order = await adminServices.GetOrderAsync(id);

            if (order == null)
            {
                return(NotFound());
            }
            respons.ResponsViewModel = adminServices.UpdateOrderStatus(id, orderStatus);
            respons.Order            = order;

            return(View(respons));
        }
Exemplo n.º 6
0
 /// <summary>
 /// Gibt die Anzahl der noch Offenen Aufträge zurück
 /// </summary>
 /// <param name="dbContext"></param>
 /// <param name="OrdertypeName">z. B Zulassung</param>
 /// <returns>Int</returns>
 public static int getUnfineshedOrdersCount(DataClasses1DataContext dbContext, OrderTypes orderType, OrderStatusTypes orderStatus)
 {
     return dbContext.Order.Count(q => q.Status == (int)orderStatus &&
         q.OrderType.Id == (int)orderType && q.HasError.GetValueOrDefault(false) != true);
 }