public IActionResult Index() { if (string.IsNullOrEmpty(HttpContext.Session.GetString("HouseId"))) { return RedirectToAction("Login", "Account"); } var currentUserId = long.Parse(HttpContext.Session.GetString("UserId")); var currentUser = _context.Users.Find(currentUserId); ViewData["Username"] = currentUser.Username; var currentHouseId = long.Parse(HttpContext.Session.GetString("HouseId")); var displayObjects = GetDisplayObject(currentHouseId); var homeDisplayModel = new HomeDisplayModel() { Messages = GetMessages(currentHouseId), BaseObjects = displayObjects }; if (_context.HouseStatuses.Where(x => x.HouseId == currentHouseId).Any()) { homeDisplayModel.HouseStatus = _context.HouseStatuses.Where(x => x.HouseId == currentHouseId).OrderByDescending(x => x.Id).FirstOrDefault(); } if (_context.HouseSettings.Any(x => x.HouseId == currentHouseId)) { homeDisplayModel.RentDueDate = GetRentDueDate(); } return View(homeDisplayModel); }
public static String GetHomeItemDetails(HomeDisplayModel selectedHome) { //var fHomeSalesCollection = CollectionFactory.GetHomeSalesCollectionObject(); //var fPeopleCollection = CollectionFactory.GetPeopleCollectionObject(); //var fHomesCollection = CollectionFactory.GetHomesCollectionObject(); if (selectedHome != null) { var homeForSale = (from hfs in ((App)Application.Current)._homeSalesCollection where hfs.HomeID == selectedHome.HomeID && hfs.MarketDate != null select hfs).FirstOrDefault(); DateTime?placeholder = null; if (homeForSale != null && homeForSale.Buyer == null) { placeholder = homeForSale.MarketDate; } var SelectedHomeDetail = (from h in ((App)Application.Current)._homesCollection where h.HomeID == selectedHome.HomeID join p in ((App)Application.Current)._peopleCollection on h.OwnerID equals p.PersonID select new HomeDisplayDetailModel { HomeID = h.HomeID, Address = h.Address, City = h.City, State = h.State, Zip = h.Zip, MarketDate = placeholder, owner = new OwnerModel { OwnerID = p.PersonID, FirstName = p.FirstName, LastName = p.LastName, Phone = p.Phone, Email = p.Email, PreferredLender = p.Owner.PreferredLender } }).FirstOrDefault(); if (SelectedHomeDetail != null) { return(SelectedHomeDetail.ToStackedString()); } } return("Select an item in the list above before clicking Get Details button."); }
public ActionResult Index() { var todayDate = DateTime.Now; var orderedEvents = _eventRepository.Filter(x => x.EventDate.CompareTo(todayDate) > 0 || x.EventDate.CompareTo(todayDate.Date) == 0) .OrderBy(x => x.EventDate).ToList(); var amountEvents = orderedEvents.Count; if (amountEvents > 4) { orderedEvents = orderedEvents.GetRange(0, 4); } var homeDisplayModel = new HomeDisplayModel { EventDisplayModels = orderedEvents.Select(n => new EventDisplayModel { Id = n.Id, Photo = n.Photo, Description = n.Description, EventDate = n.EventDate.ToString("dd MMM", new CultureInfo("es-ES")).ToUpper(), Place = n.Place, Title = n.Title, ScheduleTime = n.StartTime + " - " + n.FinishTime }), ProfileDisplayModels = _profileRepository.GetAllProfiles().Select(n => new ProfileDisplayModel { Id = n.Id, Description = n.Description, FullName = n.FullName, Photo = n.Photo }) }; return(View(homeDisplayModel)); }