Esempio n. 1
0
        //
        // GET: /Account/Login
        public ActionResult ShowProfile()
        {
            //var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
            var user = UserManager.FindById(User.Identity.GetUserId());
            ProfileViewModel profile = new ProfileViewModel();
            //profile.UserName = user.UserName;
            profile.FirstName = user.FirstName;
            profile.LastName = user.LastName;
            profile.Email = user.Email;
            if (user.Gender == "F")
                profile.Gender = "Female";
            else
                profile.Gender = "Male";

            profile.ImageUrl = user.ImageUrl;
            profile.BirthDate = getBirthdateAndAge(user.BirthDate.Value);
            profile.Address = user.HomeAddress;
            profile.InterestsToDisplay = InterestsFromObjects.GetInterestsForDisplay(user.Interests.ToList());

            List<Event> attendingEvents = db.EventVsAttendingUsers.Where(e => e.UserId == user.Id).Select(e => e.Event).Where(x => x.DateTimeOfTheEvent >= DateTime.Today).ToList();
            int thisMonth = DateTime.Today.Month;
            List<EventsByMonth> eventsByMonth = new List<EventsByMonth>();

            getMonthEvents(thisMonth, 12, attendingEvents, eventsByMonth);
            getMonthEvents(1, thisMonth - 1, attendingEvents, eventsByMonth);

            List<Event> createdEvents = db.Events.Where(e => e.CreatorUser.Id == user.Id && e.EventStatus == e_EventStatus.Active).OrderByDescending(x => x.DateTimeOfTheEvent).ToList();
            List<EventsByMonth> createdEventsByMonth = new List<EventsByMonth>();

            getMonthEvents(thisMonth, 12, createdEvents, createdEventsByMonth);
            getMonthEvents(1, thisMonth - 1, createdEvents, createdEventsByMonth);


            List<Event> pastEvents = db.EventVsAttendingUsers.Where(e => e.UserId == user.Id).Select(e => e.Event).Where(x => x.DateTimeOfTheEvent < DateTime.Today).OrderByDescending(x => x.DateTimeOfTheEvent).ToList();

            ViewData["EventsByMonth"] = eventsByMonth;
            ViewData["CreatedEventsByMonth"] = createdEventsByMonth;
            ViewData["PastEvents"] = pastEvents;

            //profile.Events = attendingEvents;
            return View(profile);
        }
Esempio n. 2
0
 //
 // GET: /Account/Login
 public async Task<ActionResult> ShowProfile(string returnUrl)
 {
     var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
     ProfileViewModel profile = new ProfileViewModel();
     //profile.UserName = user.UserName;
     profile.FirstName = user.FirstName;
     profile.LastName = user.LastName;
     profile.Email = user.Email;
     if (user.Gender == "F")
         profile.Gender = "Female";
     else
         profile.Gender = "Male";
     //add age
     profile.Interests = null;
     profile.Events = null;
     profile.ImageUrl = user.ImageUrl;
     profile.BirthDate = getBirthdateAndAge(user.BirthDate);
     profile.Address = user.HomeAddress;
     return View(profile);
 }
Esempio n. 3
0
        public ActionResult Details(string id)
        {
            ViewData["Id"] = id;
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ApplicationUser @user = db.Users.Find(id);
            if (@user == null)
            {
                return HttpNotFound();
            }
            ProfileViewModel profileToShow = new ProfileViewModel()
            {
                Address = @user.HomeAddress,
                BirthDate = getBirthdateAndAge(user.BirthDate.Value),
                Email = @user.Email,
                Interests = @user.Interests,
                //Events = @user.Events,
                FirstName = @user.FirstName,
                Gender = @user.Gender,
                LastName = @user.LastName,
                ImageUrl = @user.ImageUrl,
                UserName = @user.UserName,
                InterestsToDisplay = InterestsFromObjects.GetInterestsForDisplay(user.Interests.ToList())
            };

            List<Event> attendingEvents = db.EventVsAttendingUsers.Where(e => e.UserId == user.Id).Select(e => e.Event).Where(x => x.DateTimeOfTheEvent >= DateTime.Today).ToList();
            int thisMonth = DateTime.Today.Month;
            List<EventsByMonth> eventsByMonth = new List<EventsByMonth>();

            getMonthEvents(thisMonth, 12, attendingEvents, eventsByMonth);
            getMonthEvents(1, thisMonth - 1, attendingEvents, eventsByMonth);

            List<Event> createdEvents = db.Events.Where(e => e.CreatorUser.Id == user.Id && e.EventStatus == e_EventStatus.Active).OrderByDescending(x => x.DateTimeOfTheEvent).ToList();
            List<EventsByMonth> createdEventsByMonth = new List<EventsByMonth>();

            getMonthEvents(thisMonth, 12, createdEvents, createdEventsByMonth);
            getMonthEvents(1, thisMonth - 1, createdEvents, createdEventsByMonth);


            List<Event> pastEvents = db.EventVsAttendingUsers.Where(e => e.UserId == user.Id).Select(e => e.Event).Where(x => x.DateTimeOfTheEvent < DateTime.Today).OrderByDescending(x => x.DateTimeOfTheEvent).ToList();

            ViewData["EventsByMonth"] = eventsByMonth;
            ViewData["CreatedEventsByMonth"] = createdEventsByMonth;
            ViewData["PastEvents"] = pastEvents;
            return View(profileToShow);
        }