public void RemoveTable(int ReservationID, int TableID)                         //Remove Table (TR)
        {
            Table_Reservation table_Reservation = GetTable_ReservationById(ReservationID, TableID);

            _context.Table_Reservations.Remove(table_Reservation);
            _context.SaveChanges();
        }
 public string GetAreaByID(int ReservationID)                                    // Get the area of a reservation (using
 {
     try
     {
         Table_Reservation td = GetTable_ReservationById(ReservationID);
         Table             t  = GetTableByID(td.TableID);
         return(t.Area);
     }
     catch { return(""); }
 }
        public void AddTable(int ReservationID, int TableID)                            //set a Table to Reservation
        {
            Table_Reservation table_Reservation = new Table_Reservation()
            {
                TableID       = TableID,
                ReservationID = ReservationID,
            };

            _context.Table_Reservations.Add(table_Reservation);
            _context.SaveChanges();
        }
        public ActionResult MakeReservation(string date, string Stime, string Etime)
        {
            if (Session["UserId"] == null)
            {
                return(View("~/Views/HomePage/Login.cshtml"));
            }
            else if (Session["table"] != null && date != "" && Stime != "" && Etime != "" && date != null)
            {
                RestaurantEntities db = new RestaurantEntities();
                List <TableCartCreateViewModel> list = (List <TableCartCreateViewModel>)Session["table"];

                Table_Cart_Make tc = new Table_Cart_Make();
                tc.Customer_Id = (int)Session["UserId"];
                tc.Status      = "Pending";
                tc.Date        = date;
                tc.Start_time  = Stime;
                tc.End_Time    = Etime;

                db.Table_Cart_Make.Add(tc);
                db.SaveChanges();

                int TableCartId = db.Table_Cart_Make.Max(x => x.Table_Cart_Id);

                foreach (var item in list)
                {
                    Table_Reservation tr = new Table_Reservation();
                    tr.Table_Cart_id = TableCartId;
                    tr.Table_Id      = item.Table_Id;

                    db.Table_Reservation.Add(tr);
                    db.SaveChanges();
                }

                Session["table"] = null;
            }

            List <ReservationOverViewModel> list2 = getAllReservation();

            //return View("~/Views/HomePage/Index.cshtml");
            return(View("ShowAllReservation", list2));
        }
        public IActionResult Index()
        {
            var             Sittings = _services.GetListSitting();
            ReportViewModel model    = new ReportViewModel()
            {
                //for Sittings
                AllSittings = Sittings,
                SittingID   = Sittings[0].SittingID
            };

            try
            {
                List <Sitting>     s  = _services.GetListSitting();
                List <Reservation> Rs = _services.GetAllReservation();
                int cs = 0;
                foreach (Reservation r in Rs)
                {
                    Table_Reservation td = _services.GetTable_ReservationById(r.ReservationID);
                    if (td != null)
                    {
                        Table t = _services.GetTableByID(td.TableID);
                        //area
                        if (t.Area == "Main Room")
                        {
                            model.MainRoom++;
                        }
                        if (t.Area == "Balcony")
                        {
                            model.Balcony++;
                        }
                        if (t.Area == "Outside")
                        {
                            model.OutSide++;
                        }
                    }
                    cs = cs + r.NumberOfGuests;
                    //source
                    if (r.Source == "WebSite")
                    {
                        model.Website++;
                    }
                    if (r.Source == "Mobile")
                    {
                        model.Mobile++;
                    }
                    if (r.Source == "Walk in")
                    {
                        model.InPErson++;
                    }
                    //sitting
                    if (r.SittingID == s[0].SittingID)
                    {
                        model.Breakfast++;
                    }
                    if (r.SittingID == s[1].SittingID)
                    {
                        model.Lunch++;
                    }
                    if (r.SittingID == s[2].SittingID)
                    {
                        model.Dinner++;
                    }
                }
                model.Reservations = Rs.Count();
                model.Clients      = cs;
                return(View(model));
            }
            catch { return(RedirectToAction("Error", "Home")); }
        }
Пример #6
0
            public async static void SetReservation(
                //List<Table_Reservation> Res,
                //List<Table_Reserv_Event> Res_Ev, List<Table_Reserv_Event_Detail> Res_EvDe,
                //string _user_id,string _event_status,Object table1,Object table2
                )
            {
                using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    var NowTime = DateTime.Now.ToString("yyyyMMddhhmmss");
                    var Res     = new Table_Reservation()
                    {
                        user_id   = "test006",
                        reserv_id = string.Concat("RES", NowTime),
                        //測試用預約時間
                        reserv_time     = DateTime.Now,
                        event_status    = string.Concat(0, (int)Enum_Reserv_Status.Start),
                        create_time     = DateTime.Now,
                        reserv_event_id = string.Concat("RES_EV", NowTime)
                    };

                    var Res_Ev = new Table_Reserv_Event()
                    {
                        event_id        = string.Concat("RES_EV", NowTime),
                        event_name      = "",
                        event_detail_id = string.Concat("RES_DET", NowTime)
                    };

                    var Res_Det = new Table_Reserv_Event_Detail()
                    {
                        event_detail_id   = string.Concat("RES_DET", NowTime),
                        event_needed_item = "testitem",
                        amount            = 4564,
                        unit = "元"
                    };

                    string sqlCommand1 = @"INSERT INTO 
                                            _Reservation
                                                (user_id, reserv_id, reserv_time,event_status,create_time,reserv_event_id) 
                                            VALUES(@user_id,@reserv_id, @reserv_time,@event_status,@create_time,@reserv_event_id);";

                    string sqlCommand2 = @"INSERT INTO 
                                            _Reserv_Event
                                                (event_id, event_name, event_detail_id) 
                                            VALUES(@event_id, @event_name, @event_detail_id);";
                    string sqlCommand3 = @"INSERT INTO 
                                            _Reserv_Event_Detail
                                                (event_detail_id, event_needed_item, amount,unit) 
                                            VALUES(@event_detail_id, @event_needed_item, @amount,@unit);";

                    using (var conn = new SqlConnection(_connStr))
                    {
                        conn.Open();

                        await conn.ExecuteAsync(sqlCommand1, Res);

                        await conn.ExecuteAsync(sqlCommand2, Res_Ev);

                        await conn.ExecuteAsync(sqlCommand3, Res_Det);
                    }
                    transactionScope.Complete();
                }
            }