private bool TryShiftUpcomingReservationToOtherAvailableTable(UsersContext db, Reservation upcomingReservation)
        {
            ReservationVM model;
            IList<Int64> upcomingTableIds;
            IList<Int64> smallTableIds;
            var availableTable = db.GetAvailableFloorTables(upcomingReservation, out upcomingTableIds, out smallTableIds, out model, true, true)
                .Where(t => t.FloorTableId != upcomingReservation.FloorTableId);
            //.FirstOrDefault();

            #region Check for entries in tableavailabilities
            /**** Table availability feature enabled  start here *****/

            var tt = model.time.Split('-');
            var startTm = model.resDate.Add(DateTime.ParseExact(tt[0].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay);
            var endTime = new DateTime();
            if (string.IsNullOrEmpty(model.Duration))
            {
                endTime = model.resDate.Add(DateTime.ParseExact(tt[1].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay);
            }
            else
            {
                endTime = startTm.AddMinutes(model.Duration.GetMinutesFromDuration());
            }

            var day = upcomingReservation.ReservationDate.DayOfWeek.ToString();
            var dId = db.GetWeekDays().Single(p => p.DayName.Contains(day)).DayId;

            var availList = db.tabTableAvailabilities
                .Include("TableAvailabilityFloorTables")
                .Include("TableAvailabilityWeekDays")
                .Where(ta => ta.StartDate <= model.resDate && model.resDate <= ta.EndDate
                && ta.TableAvailabilityWeekDays.Any(taw => taw.DayId == dId)).ToList();

            var blockList = db.GetFloorTableBlockTimeList(model.resDate);

            availableTable = availableTable.Where(t => availList.CheckAvailStatus(model.resDate, startTm, endTime, t, 1)
                && !blockList.IsTableBlocked(t.FloorTableId, startTm, endTime)).ToList();

            /**** Table availability feature enabled end here *****/
            #endregion

            var firstAvailableTable = availableTable.FirstOrDefault();

            if (firstAvailableTable != null)
            {
                upcomingReservation.FloorTableId = firstAvailableTable.FloorTableId;
                upcomingReservation.TablePositionLeft = firstAvailableTable.TLeft;
                upcomingReservation.TablePositionTop = firstAvailableTable.TTop;
                db.Entry(upcomingReservation).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return true;
            }

            return false;
        }
        private void ExtendReservationDuration(int minToAdd, UsersContext db, Reservation res, out string oldDuration)
        {
            oldDuration = res.Duration;
            var newDuration = oldDuration.AddMinutesToDuration(minToAdd);

            res.Duration = newDuration;
            res.TimeTo = res.TimeForm.AddMinutes(newDuration.GetMinutesFromDuration());
            db.Entry(res).State = System.Data.Entity.EntityState.Modified;
            //db.LogEditReservation(reservation, loginUser, null);

            db.SaveChanges();
        }