public IActionResult Index()
        {
            var viewModel = new IndexVIewModel
            {
                Year    = DateTime.UtcNow.Year,
                Message = this.configuration["YouTube:ApiKey"],
                Names   = new List <string> {
                    "pesho", "gosho", "todor"
                },
            };

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            var builds = this.buildService.GetAllAsync <BuildViewModel>(10);
            var blogs  = await this.blogService.GetAllAsync <BlogViewModel>(3);

            var indexViewModel = new IndexVIewModel()
            {
                Blogs  = blogs,
                Builds = builds,
            };

            return(this.View(indexViewModel));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Manage(string company, string date, int page = 1,
                                                 SortState sortOrder = SortState.CheckInAsc)
        {
            int             pageSize = 10;
            ApplicationUser user     = new ApplicationUser();
            var             users    = _userManager.Users.ToList();

            if (User.Identity.IsAuthenticated)
            {
                user = users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();
            }
            if (user == null)
            {
                return(NotFound());
            }

            var Restaraunt = _context.RestaurantsList.Where(t => t.ID == user.RestaurantID).FirstOrDefault();

            if (Restaraunt == null)
            {
                return(Redirect("/Home/Contact"));
            }

            var halls = _context.Halls.Where(h => h.RestaurantID == Restaraunt.ID);

            if (halls.Count() < 1)
            {
                return(Redirect("/Home/Contact"));
            }
            List <HallSimple> SelectedHallsList = new List <HallSimple>();

            foreach (Hall h in halls)
            {
                HallSimple Temp = new HallSimple {
                    HallID = h.ID, HallName = h.Name
                };
                SelectedHallsList.Add(Temp);
            }
            var table = _context.TablesList.Join(halls, T => T.HallID,
                                                 H => H.ID,
                                                 (T, H) => new { id = T.ID, hallid = H.ID, tablename = T.Name, hallname = H.Name }
                                                 ).ToList();
            IQueryable <ManageBookingViewModel> bookings = _context.Bookings.Join(table, B => B.TableID,
                                                                                  T => T.id,
                                                                                  (B, T) => new ManageBookingViewModel
            {
                BookingID     = B.ID,
                CheckIn       = B.CheckIn,
                CheckOut      = B.CheckOut,
                Completed     = B.Completed,
                CustomerName  = B.CustomerName,
                CustomerPhone = B.CustomerPhone,
                Guests        = B.Guests,
                Paid          = B.Paid,
                HallID        = T.hallid,
                HallName      = T.hallname,
                TableName     = T.tablename,
                TableID       = B.TableID
            }
                                                                                  );

            if (company != null && company != "0")
            {
                bookings = bookings.Where(p => p.HallID == company);
            }

            DateTime SD = DateTime.MinValue;
            DateTime dateValue;

            if (DateTime.TryParse(date, out dateValue))
            {
                SD       = Convert.ToDateTime(date);
                bookings = bookings.Where(p => p.CheckIn >= SD);
            }

            switch (sortOrder)
            {
            case SortState.CheckInDesc:
                bookings = bookings.OrderByDescending(s => s.CheckIn);
                break;

            case SortState.PhoneAsc:
                bookings = bookings.OrderBy(s => s.CustomerPhone);
                break;

            case SortState.PhoneDesc:
                bookings = bookings.OrderByDescending(s => s.CustomerPhone);
                break;

            case SortState.HallAsc:
                bookings = bookings.OrderBy(s => s.HallName);
                break;

            case SortState.HallDesc:
                bookings = bookings.OrderByDescending(s => s.HallName);
                break;

            default:
                bookings = bookings.OrderBy(s => s.CheckIn);
                break;
            }

            var count = await bookings.CountAsync();

            var items = await bookings.Skip((page - 1) *pageSize).Take(pageSize).ToListAsync();

            IndexVIewModel viewModel = new IndexVIewModel
            {
                PageViewModel   = new PageViewModel(count, page, pageSize),
                SortViewModel   = new SortViewModel(sortOrder),
                FilterViewModel = new FilterViewModel(SelectedHallsList, company, SD),
                Bookings        = items
            };


            return(View(viewModel));
        }