// GET: User/Lists public ActionResult Lists() { if (Session["UserId"] != null) { ViewBag.Message = TempData["SuccessMessage"]; ViewBag.Error = TempData["ErrorMessage"]; //TODO: Logic to show all lists of a user int userId = int.Parse(Session["UserId"].ToString()); ShoppingListService listService = new ShoppingListService(); var listOfLists = listService.GetListsByUserId(userId).OrderByDescending(x => x.TimeStamp).ToList(); if (listOfLists.Count() == 0) { ViewBag.Message = "You don't have any lists yet. Start creating your lists now!"; } ListsVM lists = new ListsVM { AllUserLists = listOfLists }; return(View(lists)); } else { return(RedirectToAction("Login", "User")); } }
private GenricApartment <ListsVM, RentVM, SaleVM, ApartmentVM> PopulateLists(string lists, Action <Rent, Sale, Apartment> action) { ListsVM listsVm = new ListsVM() { Bedrooms = lists.GetSelectListAsync("bedrooms", "bedroomsCount"), Countries = lists.GetSelectListAsync("countries", "country").OrderBy(o => o.Text), Furnishings = lists.GetSelectListAsync("furnishings", "furnitureType"), Owners = lists.GetSelectListAsync("owners", "fullName").OrderBy(o => o.Text) }; RentVM rent = new RentVM() { Periods = lists.GetSelectListAsync("periods", "period") }; SaleVM sale = new SaleVM(); ApartmentVM apartment = new ApartmentVM(); action.Invoke(rent.Rent, sale.Sale, apartment.Apartment); return(new GenricApartment <ListsVM, RentVM, SaleVM, ApartmentVM>(listsVm, rent, sale, apartment)); }