public ActionResult ChangeOrderStatus(int orderId, int goodAmount, bool IsPay = false, bool IsCancel = false, bool IsEnd = false)
 {
     if (goodAmount > 0)
     {
         Order o = pcComponentsUnit.Orders.GetElement(orderId);
         if (o != null)
         {
             if (IsPay)
             {
                 o.OrderStatus = OrderStatus.Paid.ToString();
                 o.PaidAt      = DateTime.Now;
             }
             else if (IsCancel)
             {
                 o.OrderStatus = OrderStatus.Canceled.ToString();
             }
             else if (o.OrderStatus == OrderStatus.Paid.ToString() && IsEnd)
             {
                 o.OrderStatus = OrderStatus.Finished.ToString();
             }
             OrderInfoEvent($"Order({o.OrderId}) status has been changed to {o.OrderStatus}\nOwner name:{o.UserName}");
             o.GoodAmount = goodAmount;
             pcComponentsUnit.Orders.Update(o);
             pcComponentsUnit.Save();
         }
     }
     return(RedirectToActionPermanent("Orders"));
 }
        public ActionResult ChangeOrderStatus(int orderId, string newStatus)
        {
            Order order = pcComponentsUnit.Orders.GetElement(orderId);

            if (order != null)
            {
                string orderStatus = pcComponentsUnit.Orders.GetElement(orderId).OrderStatus;
                if (newStatus != orderStatus && Enum.GetNames(typeof(OrderStatus)).Contains(newStatus) &&
                    !"Registered, Finished".Contains(newStatus))
                {
                    order.OrderStatus = newStatus;
                    pcComponentsUnit.Orders.Update(order);
                    pcComponentsUnit.Save();
                    OrderInfoEvent($"Order({order.OrderId}) status has been changed to {order.OrderStatus}\nOwner name:{order.UserName}");
                }
            }
            return(View("Orders", pcComponentsUnit.Orders.GetAll()));
        }
Example #3
0
        public ActionResult CreateGood(string category)
        {
            int goodId = 0;

            switch (category)
            {
            case "Процессоры":
                pcComponentsUnit.Processors.Create(new Processor()
                {
                    Category = category
                });
                pcComponentsUnit.Save();
                goodId = pcComponentsUnit.Processors.GetAll().Last().ID;
                break;

            case "Материнские платы":
                pcComponentsUnit.Motherboards.Create(new Motherboard()
                {
                    Category = category
                });
                pcComponentsUnit.Save();
                goodId = pcComponentsUnit.Motherboards.GetAll().Last().ID;
                break;

            case "Видеокарты":
                pcComponentsUnit.VideoCards.Create(new VideoCard()
                {
                    Category = category
                });
                pcComponentsUnit.Save();
                goodId = pcComponentsUnit.VideoCards.GetAll().Last().ID;
                break;

            case "Корпуса":
                pcComponentsUnit.ComputerСases.Create(new ComputerCase()
                {
                    Category = category
                });
                pcComponentsUnit.Save();
                goodId = pcComponentsUnit.ComputerСases.GetAll().Last().ID;
                break;

            case "Модули памяти":
                pcComponentsUnit.MemoryModules.Create(new MemoryModule()
                {
                    Category = category
                });
                pcComponentsUnit.Save();
                goodId = pcComponentsUnit.MemoryModules.GetAll().Last().ID;
                break;

            case "Блоки питания":
                pcComponentsUnit.PowerSupplies.Create(new PowerSupply()
                {
                    Category = category
                });
                pcComponentsUnit.Save();
                goodId = pcComponentsUnit.PowerSupplies.GetAll().Last().ID;
                break;

            case "SSD диски":
                pcComponentsUnit.SSDDrives.Create(new SSDDrive()
                {
                    Category = category
                });
                pcComponentsUnit.Save();
                goodId = pcComponentsUnit.SSDDrives.GetAll().Last().ID;
                break;
            }
            return(RedirectToActionPermanent("ChangeOrDeleteGood", new { goodId, category, IsChangeGood = true }));
        }