Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,DateTime,NumOfDinners,Note,Kitchen")] Reservation reservation, Client client)
        {
            ViewData["Reservation"] = "orderres";
            var existclient = _context.Client.FirstOrDefault(c => c.Id == client.Id);

            if (existclient == null)
            {
                _context.Client.Add(client);
                _context.SaveChanges();
            }
            reservation.Client = client;
            _context.Reservasion.Add(reservation);
            _context.SaveChanges();


            return(View(reservation));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Content")] Contact contact, Client client)
        {
            //popup for contact
            ViewData["Contact"] = "Order";

            var existclient = _context.Client.FirstOrDefault(c => c.Id == client.Id);

            if (existclient == null)
            {
                _context.Client.Add(client);
                _context.SaveChanges();
            }

            contact.InfoClient = client;
            _context.Contact.Add(contact);
            _context.SaveChanges();

            return(View(contact));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Total")] Order order, Client client
                                                 , string cardNumber, string expiryMonth, string expiryYear,
                                                 string cvv, string CreditOwnerName)
        {
            //if (ModelState.IsValid)
            ViewData["Order"] = "order";
            int j = 0;

            order = globalOrder;

            //check if client did order in the past.
            var existsClient = _context.Client.FirstOrDefault(c => c.Id == client.Id);

            //if is new client, add him to the system.
            if (existsClient == null)
            {
                _context.Client.Add(client);
                _context.SaveChanges();
            }

            bool success = true;    //should use payment paramters for perform payment. now ignore it.     :))))))))))))))))BE HAPPY))))))))))))))))))

            if (success)
            {
                //enter the order to DB
                order.Client = client;
                _context.Add(order);
                await _context.SaveChangesAsync();

                globalOrder = order;

                string   cart      = HttpContext.Session.GetString("Cart");
                string[] DishesIds = cart.Split(",", StringSplitOptions.RemoveEmptyEntries);
                string[] Ids_NonDuplicate;

                Ids_NonDuplicate = RemoveDuplicates(DishesIds);

                foreach (var id in Ids_NonDuplicate)
                {
                    DeleteDIshesOrder(int.Parse(id), order);
                }
                HttpContext.Session.SetString("Cart", "");
            }
            // else
            //   {
            //  ViewBag.OrderFailed = "מצטערים הזמנה נכשלה. אנא צרו קשר עם שירות לקוחות";
            // }

            //}

            //return View(order);
            return(RedirectToAction("OrderDone"));
        }