Beispiel #1
0
        public async Task <ActionResult> Delete()
        {
            orderSes = (OrderSes)Session["OrdSes"];
            await repo.Delete(orderSes.id);

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Edit(int id)
        {
            orderSes          = (OrderSes)Session["OrdSes"];
            orderSes.id       = id;
            orderSes.act      = "Редактировать " + orderSes.Prefix;
            Session["OrdSes"] = orderSes;

            return(RedirectToAction("Booking"));
        }
Beispiel #3
0
 public async Task <ActionResult> Products(OrderProductView svd)
 {
     orderSes = (OrderSes)Session["OrdSes"];
     if (Session["Products"] != null)
     {
         await repo.SaveDetail(orderSes.id, svd);
     }
     return(RedirectToAction("Booking", "Order", new { id = orderSes.id }));
 }
Beispiel #4
0
        public async Task <ActionResult> DelTrans(string id)
        {
            orderSes = (OrderSes)Session["OrdSes"];
            OrderDriv drv = await db.OrderDrivs.Where(t => t.OrderId == orderSes.id).FirstOrDefaultAsync(o => o.Gn == id);

            db.OrderDrivs.Remove(drv);
            await db.SaveChangesAsync();

            return(RedirectToAction("Booking"));
        }
Beispiel #5
0
        public async Task <ActionResult> Delete(int id)
        {
            orderSes          = (OrderSes)Session["OrdSes"];
            orderSes.id       = id;
            orderSes.act      = "Удаление заказа";
            Session["OrdSes"] = orderSes;
            order             = await repo.GetChange(orderSes.id);

            ViewBag.Order = "Удаление заказа";
            return(View(order));
        }
Beispiel #6
0
        public async Task <ActionResult> Index()
        {
            Session["ChProducts"] = null;
            Session["Products"]   = null;
            Session["trans"]      = null;
            orderSes = (OrderSes)Session["OrdSes"];
            List <OrderV> orders = await repo.GetOrder(Cust.CustId, orderSes.OrderType);

            ViewBag.Title = orderSes.act;
            return(View(orders));
        }
Beispiel #7
0
        public async Task <ActionResult> Copy(int id)
        {
            orderSes = (OrderSes)Session["OrdSes"];
            order    = await repo.GetCopy(id, orderSes.OrderType);

            orderSes.id = order.OrderId;
            string cord = id.ToString();

            //orderSes.act = "Копия заказа №"+ cord+" Новый заказ";
            orderSes.act      = "Новый " + orderSes.Prefix;
            Session["OrdSes"] = orderSes;
            return(RedirectToAction("Booking"));
        }
Beispiel #8
0
        public async Task <ActionResult> Create()
        {
            orderSes = (OrderSes)Session["OrdSes"];
            string email = User.Identity.GetUserName();

            order = await repo.GetCreate(Cust.CustId, orderSes.OrderType, email);

            //order.email = User.Identity.GetUserName();
            orderSes.id       = order.OrderId;
            orderSes.act      = "Новый " + orderSes.Prefix;
            Session["OrdSes"] = orderSes;
            return(RedirectToAction("Booking"));
        }
Beispiel #9
0
        public async Task <ActionResult> NewAdres(Adres adres)
        {
            adres.CustId = Cust.CustId;
            db.Adreses.Add(adres);
            await db.SaveChangesAsync();

            orderSes = (OrderSes)Session["OrdSes"];
            order    = await repo.GetChange(orderSes.id);

            order.AdresId = adres.AdresID;
            await repo.Save(order);

            return(RedirectToAction("Booking"));
        }
Beispiel #10
0
 public async Task <ActionResult> CreateTec(TrustTecDet det)
 {
     if (ModelState.IsValid)
     {
         orderSes = (OrderSes)Session["OrdSes"];
         OrderDriv drv = new OrderDriv();
         drv.OrderId  = orderSes.id;
         drv.Gn       = det.Gn;
         drv.TecModel = det.TecModel;
         db.OrderDrivs.Add(drv);
         await db.SaveChangesAsync();
     }
     return(RedirectToAction("Booking"));
 }
Beispiel #11
0
        public async Task <ActionResult> Booking()
        {
            orderSes = (OrderSes)Session["OrdSes"];

            order = await repo.GetChange(orderSes.id);

            Session["Products"] = order.Products;
            ViewBag.Order       = orderSes.act;
            if (orderSes.OrderType == 0)
            {
                ViewBag.Order = orderSes.act + " №  " + orderSes.id.ToString();
            }
            return(View(order));
        }
Beispiel #12
0
        public async Task <ActionResult> NewDriv(string gn)
        {
            if (gn != null)
            {
                //Session["trans"] = null;
                Transport trans = await db.Transports.Where(t => t.CustID == Cust.CustId).FirstOrDefaultAsync(o => o.Gn == gn);

                orderSes = (OrderSes)Session["OrdSes"];
                OrderDriv drv = new OrderDriv();
                drv.OrderId  = orderSes.id;
                drv.Gn       = gn;
                drv.TecModel = trans.TecModel;
                db.OrderDrivs.Add(drv);
                await db.SaveChangesAsync();
            }
            return(RedirectToAction("Booking"));
            //View(await db.Transports.Where(t => t.CustID == Menu.CustId).ToListAsync());
        }
Beispiel #13
0
        public async Task <ActionResult> NewContact(Person person)
        {
            try
            {
                person.CustId = Cust.CustId;
                db.Persons.Add(person);
                await db.SaveChangesAsync();

                orderSes = (OrderSes)Session["OrdSes"];
                order    = await repo.GetChange(orderSes.id);

                order.PersonId = person.PersonId;
                await repo.Save(order);

                return(RedirectToAction("Booking"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #14
0
        public async Task <ActionResult> Booking(OrderView ord, string Gd, string Adr, string Prs, string Trans)
        {
            string email = User.Identity.GetUserName();
            List <OrderProductView> products = (List <OrderProductView>)Session["Products"];

            orderSes = (OrderSes)Session["OrdSes"];
            if (ModelState.IsValid && Gd == null && Adr == null && Prs == null && Trans == null && ord.StatusId == 0)
            {
                //Значит именно сохроанение
                if (products.Any())
                {
                    ord.StatusId = 1;
                    await repo.Save(ord, products, email);

                    order = await repo.GetChange(ord.OrderId);

                    order.Products = products;
                    ViewBag.Order  = orderSes.Prefix + " отправлен";
                    if (orderSes.OrderType == 0)
                    {
                        ViewBag.Order = "Заказ №  " + orderSes.id.ToString() + " отправлен";
                    }

                    if (orderSes.OrderType == 1)
                    {
                        ViewBag.Order = "Счет №  " + orderSes.id.ToString() + " отправлен";
                    }

                    return(View("Saved", order));
                }
                else
                {
                    ord.StatusId = 9;
                    await repo.Save(ord, products, email);

                    return(View("NotSaved", order));
                }
            }

            //Уходя на другой объект, сохранить заполненное!
            //Проверить что все заполнено, потом изменять статус
            await repo.Save(ord, products, email);

            order = await repo.GetChange(ord.OrderId);

            order.Products = products;

            if (Gd != null)
            {
                return(RedirectToAction("Index", "Good", new { act = "Products", cont = "Order" }));
            }
            if (Adr != null)
            {
                return(RedirectToAction("NewAdres"));
            }
            if (Prs != null)
            {
                return(RedirectToAction("NewContact"));
            }
            if (Trans != null)
            {
                return(RedirectToAction("Transports"));
            }

            return(RedirectToAction("Index"));
        }