public ActionResult Index(int u) { var user = ServiceManager.Kernel.Get<IUserManager>().GetById(u); if (user != null) { var userModel = new UserModel { User = user }; var friends = ServiceManager.Kernel.Get<IUserManager>().GetAll().Where(x => x.Id != user.Id).ToList(); //Get list of events that user is involved in var events = ServiceManager.Kernel.Get<IEventManager>().GetByOwnerId(user.Id); userModel.DiscoverEvents = events.Select(x => new EventModel() { Id = x.Id, Title = x.Title, Latitude = x.Location.Latitude, Longitude = x.Location.Longitude, Distance = Double.NaN, StartTime = x.StartTime }).ToList(); userModel.Friends = friends; return View(userModel); } else { return RedirectToAction("Login", "Account"); } }
public PartialViewResult RespondToInvitation(string userId, string eventId, string response) { var u = ServiceManager.Kernel.Get<IUserManager>().GetById(long.Parse(userId)); var e = ServiceManager.Kernel.Get<IEventManager>().GetById(long.Parse(eventId)); var r = ResponseType.WaitingReply; if (response.Equals("Accept")) { r = ResponseType.Accepted; } else if (response.Equals("Decline")) { r = ResponseType.Rejected; } if (e.Guests.FirstOrDefault(g => g.GuestId == long.Parse(userId)) != null) { e.Guests.FirstOrDefault(g => g.GuestId == long.Parse(userId)).Response = r; } ServiceManager.Kernel.Get<IEventManager>().Save(e); var userModel = new UserModel { User = u, UserId = u.Id.ToString(), EventInvitations = ServiceManager.Kernel.Get<IEventManager>().GetByGuestId(u.Id) }; return PartialView("_DiscoverInvitationList", userModel); }
public ActionResult DiscoverEvent(string u) { ViewBag.Message = "Discover Event page."; var user = ServiceManager.Kernel.Get<IUserManager>().GetByUserName(u); var userModel = new UserModel { User = user }; userModel.Friends = ServiceManager.Kernel.Get<IUserManager>().GetAll().ToList(); var events = ServiceManager.Kernel.Get<IEventManager>().GetAll().Where(x => x.IsPrivate == false && x.IsActive).ToList(); userModel.DiscoverEvents = events.Select(x => new EventModel() { Id = x.Id, Title = x.Title, Latitude = x.Location.Latitude, Longitude = x.Location.Longitude, Distance = Double.NaN, StartTime = TimeZone.CurrentTimeZone.ToLocalTime(x.StartTime), EndTime = TimeZone.CurrentTimeZone.ToLocalTime(x.EndTime) }).ToList(); userModel.EventInvitations = ServiceManager.Kernel.Get<IEventManager>().GetByGuestId(user.Id); return View(userModel); }