Esempio n. 1
0
        public async Task <ActionResult> Delete(int?id, string lastName, string phoneNumber, bool processed, int page = 1)
        {
            Order order = await db.Orders.Where(o => o.OrderId == id).FirstOrDefaultAsync();

            db.Orders.Remove(order);

            Tour tour = db.Tours.Where(t => t.TourId == order.TourId).FirstOrDefault();

            tour.CountOfPlace++;
            db.Update(tour);
            db.SaveChanges();

            return(RedirectToRoute(new {
                controller = "Admin",
                action = "Index",
                lastName = lastName,
                phoneNumber = phoneNumber,
                processed = processed,
                page = page
            }));
        }
Esempio n. 2
0
        public JsonResult Index(Order order)
        {
            if (db.Tours.Where(t => t.TourId == order.TourId).FirstOrDefault().CountOfPlace > 0)
            {
                order.ContactPhone = "+7" + order.ContactPhone;
                order.Processed    = false;
                db.Orders.Add(order);
                db.SaveChanges();

                Tour tour = db.Tours.Where(t => t.TourId == order.TourId).FirstOrDefault();
                tour.CountOfPlace--;
                db.Update(tour);

                var html = this.view.Render("Order/PartialView/_OrderSent", true);
                return(new JsonResult(new { isValid = true, html = html }));
            }
            else
            {
                var html = this.view.Render("Order/PartialView/_OrderSent", false);
                return(new JsonResult(new { isValid = false, html = html }));
            }
        }