Exemplo n.º 1
0
 public ActionResult ShowFreeTables(ReservationParameters model)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new RestaurantModelContext()))
     {
         TablesArrangement tablesArrangement = new TablesArrangement();
         tablesArrangement.ReservationParameters = model;
         Dictionary <int, Table> freeTables = unitOfWork.Tables.GetAllFreeTablesForRestaurant(model);
         tablesArrangement.Arrangement = new Dictionary <int, Dictionary <int, Table> >();
         foreach (var item in freeTables)
         {
             if (!tablesArrangement.Arrangement.ContainsKey(item.Value.ROW))
             {
                 tablesArrangement.Arrangement.Add(item.Value.ROW, new Dictionary <int, Table>());
             }
             tablesArrangement.Arrangement[item.Value.ROW][item.Value.COLUMN] = item.Value;
         }
         ViewBag.Title = model.Name;
         return(View(tablesArrangement));
     }
 }
Exemplo n.º 2
0
 //GET Tables
 public ActionResult TablesArrangement()
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new RestaurantModelContext()))
     {
         TablesArrangement tablesArrangement = new TablesArrangement();
         var          userIdentity           = UserManager.FindById(User.Identity.GetUserId());
         var          user         = unitOfWork.Users.FindUserByEmail(userIdentity.Email);
         List <Table> listOfTables = unitOfWork.Tables.GetAllTablesForRestaurant((int)user.RES_ID).ToList();
         tablesArrangement.Arrangement = new Dictionary <int, Dictionary <int, Table> >();
         foreach (var item in listOfTables)
         {
             if (!tablesArrangement.Arrangement.ContainsKey(item.ROW))
             {
                 tablesArrangement.Arrangement.Add(item.ROW, new Dictionary <int, Table>());
             }
             tablesArrangement.Arrangement[item.ROW][item.COLUMN] = item;
         }
         ViewBag.Title = unitOfWork.Restaurants.Get((int)user.RES_ID).NAME;
         return(View(tablesArrangement));
     }
 }