// GET: Listings
        public ActionResult Index()
        {
            var registeredUserService = new RegisteredUserService();
            var user = registeredUserService.GetRegisteredUser(this.User);

            var repo      = new ListingsRepository();
            var viewLists = new ViewLists();

            viewLists.registeredUser = user;

            if (user.Role == UserRoles.AdministratorRole)
            {
                viewLists.TopList    = repo.GetAllAvailable();
                viewLists.BottomList = repo.GetAllUnavailableExpired(DAY_LIMIT_FOR_ADMINISTRATORS);
            }

            else if (user.Role == UserRoles.GrowerRole)
            {
                viewLists.TopList    = repo.GetAvailableByGrower(user.GrowerId);
                viewLists.BottomList = repo.GetUnavailableExpired(user.GrowerId, DAY_LIMIT_FOR_GROWERS);
            }

            else if (user.Role == UserRoles.FoodBankRole)
            {
                viewLists.TopList    = repo.GetAllAvailable();
                viewLists.BottomList = repo.GetClaimedByFoodBank(user.FoodBankId, DAY_LIMIT_FOR_FOOD_BANKS);
            }

            return(View(viewLists));
        }
Beispiel #2
0
        // GET: Listings
        public ActionResult Index()
        {
            var registeredUserService = new RegisteredUserService();
            var user = registeredUserService.GetRegisteredUser(this.User);

            var repo = new ListingsRepository();
            var listingsViewModel = new ListingsViewModel();

            listingsViewModel.registeredUser = user;

            if (user.Role == UserRoles.AdministratorRole)
            {
                listingsViewModel.FirstList  = repo.GetAllAvailable();
                listingsViewModel.SecondList = repo.GetAllClaimedNotPickedUp(DAY_LIMIT_FOR_ADMINISTRATORS);
                listingsViewModel.ThirdList  = repo.GetAllUnavailableExpired(DAY_LIMIT_FOR_ADMINISTRATORS);
            }

            else if (user.Role == UserRoles.GrowerRole)
            {
                listingsViewModel.FirstList  = repo.GetAvailableByGrower(user.GrowerId);
                listingsViewModel.SecondList = repo.GetClaimedNotPickedNotExpiredUpByGrower(user.GrowerId, DAY_LIMIT_FOR_GROWERS);
                listingsViewModel.ThirdList  = repo.GetExpiredOrPickedUpByGrower(user.GrowerId, DAY_LIMIT_FOR_GROWERS);
            }

            else if (user.Role == UserRoles.FoodBankRole)
            {
                listingsViewModel.FirstList  = repo.GetAllAvailable();
                listingsViewModel.SecondList = repo.GetClaimedNotPickedUpNotExpiredByFoodBank(user.FoodBankId, DAY_LIMIT_FOR_FOOD_BANKS);
                listingsViewModel.ThirdList  = repo.GetClaimedPickedUpByFoodBankNotPickedUp(user.FoodBankId, DAY_LIMIT_FOR_FOOD_BANKS);
            }

            return(View(listingsViewModel));
        }
Beispiel #3
0
 public ListingsController(IConfiguration configuration)
 {
     repo = new ListingsRepository(configuration);
 }