Exemple #1
0
        public IActionResult AdminPanel()
        {
            var totalUsersCount = this.userServices.GetAllUsers().Count();

            var adminsCount   = this.adminServices.GetAllAdmins().Count();
            var bannedCount   = this.adminServices.GetAllBannedUsers().Count();
            var ordinaryCount = this.adminServices.GetAllOrinaryUsers().Count();

            var usersStatus = new UserStatusViewModel()
            {
                Count         = totalUsersCount,
                AdminsCount   = adminsCount,
                BannedCount   = bannedCount,
                OrdinaryCount = ordinaryCount
            };

            var carsCount = this.carServices.GetAllCars().Count();

            var carsStatus = new CarStatusViewModel()
            {
                Count         = carsCount,
                InPrcessCount = carsCount,
                ReadyCount    = 0, // TODO
                WaitingCount  = 0  // TODO
            };


            var statusesViewModel = new StatusesViewModel()
            {
                UsersStatus = usersStatus,
                CarsStatus  = carsStatus
            };

            return(this.View(statusesViewModel));
        }
Exemple #2
0
        public ViewResult List(string status = "In Use", int carPage = 1)
        {
            List <CarStatus>          cs;
            List <CarStatusViewModel> csView = new List <CarStatusViewModel>();

            //if (String.IsNullOrEmpty(status))
            //{
            //    //cs = _context.CarStatuses.Include(s => s.Status)
            //    //    .Include(s => s.Car).ThenInclude(c => c.CarModel).ThenInclude(c => c.Manufacturer)
            //    //    .Include(c => c.Unit).ThenInclude(u => u.Firm).ThenInclude(f => f.Employee)
            //    //    .Include(c => c.Unit).ThenInclude(u => u.Department)
            //    //    .Include(c => c.Location)
            //    //    .Include(c => c.Car.CarOwner)
            //    //    .ToList();
            //}
            //else
            //{
            cs = _context.CarStatuses.Include(s => s.Status)
                 .Include(s => s.Car).ThenInclude(c => c.CarModel).ThenInclude(c => c.Manufacturer)
                 .Include(c => c.Unit).ThenInclude(u => u.Firm).ThenInclude(f => f.Employee)
                 .Include(c => c.Unit).ThenInclude(u => u.Department)
                 .Include(c => c.Location)
                 .Include(c => c.Car.CarOwner)
                 .Where(s => s.Status.State == status || String.IsNullOrEmpty(s.Status.State))
                 .ToList();

            foreach (var item in cs)
            {
                CarStatusViewModel v = new CarStatusViewModel(item);
                csView.Add(v);
            }
            //}


            return(View(
                       new CarStatusListViewModel
            {
                CarStatuses = csView
                              .Skip((carPage - 1) * PageSize)
                              .Take(PageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage = carPage,
                    ItemsPerPage = PageSize,
                    TotalItems = cs.Count()
                },
                CurrentStatus = status
            }
                       ));
        }
 public TemperatureTestViewModel()
 {
     CarStatusViewModel cvm = new CarStatusViewModel(this);
 }