Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("RoomId,OrderId")] RoomsOrders roomsOrders)
        {
            if (id != roomsOrders.RoomId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(roomsOrders);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoomsOrdersExists(roomsOrders.RoomId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.Order, "Id", "ClientID", roomsOrders.OrderId);
            ViewData["RoomId"]  = new SelectList(_context.Room, "Id", "Id", roomsOrders.RoomId);
            return(View(roomsOrders));
        }
Пример #2
0
        public async Task <IActionResult> Payment(Order order,
                                                  //customer's details
                                                  Client client,
                                                  //string ID, string Name, string PhoneNumber, string Address, string Email
                                                  //payment's details
                                                  //string creditValidity,
                                                  string cardNumber,
                                                  string expiryMonth, string expiryYear,
                                                  string cvv, string idCredit, string numberOfPayment
                                                  )
        {
            order.Id = 0;
            //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();
                existsClient = client;
            }
            bool success = true;//should use payment paramters for perform payment. now ignore it.

            if (success)
            {
                //enter the order to DB
                order.Client = existsClient;
                var      roomsNumbers   = HttpContext.Session.GetString("roomsNumbers");
                string[] numbersOfRooms = roomsNumbers.Split(',');
                for (int i = 0; i < numbersOfRooms.Count(); i++)
                {
                    RoomsOrders roomOr = new RoomsOrders();
                    roomOr.RoomId = int.Parse(numbersOfRooms[i]);
                    roomOr.Order  = order;
                    roomOr.Room   = _context.Room.FirstOrDefault(r => r.Id == roomOr.RoomId);

                    if (order.Rooms == null)
                    {
                        order.Rooms = new List <RoomsOrders>();
                    }
                    order.Rooms.Add(roomOr);
                }
                _context.Order.Add(order);
                _context.SaveChanges();

                ViewBag.OrderDone = "הזמנתך התקבלה בהצלחה. מחכים לראות אותך(:";
            }
            else
            {
                ViewBag.OrderFailed = "מצטערים הזמנה נכשלה. אנא צרו קשר עם שירות לקוחות";
            }
            return(View(order));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("RoomId,OrderId")] RoomsOrders roomsOrders)
        {
            if (ModelState.IsValid)
            {
                _context.Add(roomsOrders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.Order, "Id", "ClientID", roomsOrders.OrderId);
            ViewData["RoomId"]  = new SelectList(_context.Room, "Id", "Id", roomsOrders.RoomId);
            return(View(roomsOrders));
        }