public ActionResult Index(IEnumerable<EventModel> events = null)
 {
     if (events == null) events = getEventService().GetAllEvents().Reverse().Take(10);
     UserProfileModel profile = getAccountService().GetUserProfileByUsername(User.Identity.Name);
     NotificationsShortList notifications = profile != null ? new NotificationsShortList
     {
         UnreadMessages = getEventService().GetMessages(new GetMessagesModel
         {
             GetUnreadOnly = true,
             UserProfileID = profile.UserProfileId
         }).Count(),
         FriendRequests = getAccountService().GetFriendRequests(new GetFriendRequestsModel { UserProfileId = profile.UserProfileId }).Count()
     } : null;
     if (profile == null) profile = new UserProfileModel { Avatar = "", FirstName = "", LastName = "" };
     IndexSidebarViewModel sidebar = new IndexSidebarViewModel { AvatarUrl = profile.Avatar, Name = profile.FirstName + " " + profile.LastName, Notifications = notifications, Username = User.Identity.Name };
     return View(new IndexViewModel { DisplayName = sidebar.Name, Events = events, Sidebar = sidebar });
 }
 private IndexViewModel generateIndexViewModel(IEnumerable<EventModel> events)
 {
     UserProfileModel profile = accountServices.GetUserProfileByUsername(User.Identity.Name);
     NotificationsShortList notifications = profile != null ? new NotificationsShortList
     {
         UnreadMessages = eventServices.GetMessages(new GetMessagesModel
         {
             GetUnreadOnly = true,
             UserProfileID = profile.UserProfileId
         }).Count(),
         FriendRequests = accountServices.GetFriendRequests(new GetFriendRequestsModel { UserProfileId = profile.UserProfileId }).Count()
     } : null;
     if (profile == null) profile = new UserProfileModel { Avatar = "", FirstName = "", LastName = "" };
     IndexSidebarViewModel sidebar = new IndexSidebarViewModel { AvatarUrl = profile.Avatar, Name = profile.FirstName + " " + profile.LastName, Notifications = notifications, Username = User.Identity.Name };
     return (new IndexViewModel { DisplayName = sidebar.Name, Events = events, Sidebar = sidebar });
 }