public ActionResult Details(int id) { var userId = User.Identity.GetUserId(); ApplicationUser currentUser = db.Users.FirstOrDefault(u => u.Id == userId); bool checkregistration = false; bool checkpastevent = false; Event eEvent = db.Events.SingleOrDefault(e => e.EventId == id); var query = (from usr in db.Users from eventUser in usr.EventUsers where eventUser.EventId == id select usr).ToList(); int res = DateTime.Compare(eEvent.EventDate, DateTime.Now); checkpastevent = (res < 0) ? true : false; checkregistration = query.Contains(currentUser) ? true : false; EventUserViewModel vm = new EventUserViewModel { Event = eEvent, Users = query, CheckRegistration = checkregistration, CheckPastEvent = checkpastevent }; return(View(vm)); }
public async Task <IActionResult> Profile(string id, string eId) { var profile = _context.StandardUsers.Where(x => x.Id == id).FirstOrDefault(); var eve = _context.Events.Where(x => x.Id == eId).FirstOrDefault(); EventUserViewModel EUVM = new EventUserViewModel(); EUVM.User = profile; EUVM.Event = eve; return(View(EUVM)); }
public IActionResult EventUser() { try { EventUserViewModel model = new EventUserViewModel(); var user = _repoWrapper.User. FindByCondition(q => q.Id == _userManager.GetUserId(User)).First(); model.User = user; model.EventAdmins = _repoWrapper.EventAdmin.FindByCondition(i => i.UserID == _userManager.GetUserId(User)). Include(i => i.Event).Include(i => i.User).ToList(); model.Participants = _repoWrapper.Participant.FindByCondition(i => i.UserId == _userManager.GetUserId(User)). Include(i => i.Event).ToList(); model.CreatedEventCount = 0; model.CreatedEvents = new List <Event>(); foreach (var eventAdmin in model.EventAdmins) { if (eventAdmin.UserID == _userManager.GetUserId(User)) { model.CreatedEvents.Add(eventAdmin.Event); model.CreatedEventCount += 1; } } model.PlanedEventCount = 0; model.PlanedEvents = new List <Event>(); model.VisitedEventsCount = 0; model.VisitedEvents = new List <Event>(); foreach (var participant in model.Participants) { if (participant.UserId == _userManager.GetUserId(User) && participant.Event.EventDateEnd >= DateTime.Now) { model.PlanedEvents.Add(participant.Event); model.PlanedEventCount += 1; } else if (participant.UserId == _userManager.GetUserId(User) && participant.Event.EventDateEnd < DateTime.Now && participant == _repoWrapper.Participant. FindByCondition(i => i.ParticipantStatus.ParticipantStatusName == "Учасник")) { model.VisitedEventsCount += 1; model.VisitedEvents.Add(participant.Event); } } return(View(model)); } catch { return(RedirectToAction("HandleError", "Error", new { code = 500 })); } }
public EventUserViewModel GetEventUserViewModel() { var model = new EventUserViewModel() { User = new UserViewModel() { Id = "1", FirstName = "Ігор", LastName = "Ігоренко", ImagePath = "picture.jpg", }, PlanedEvents = new List <EventGeneralInfoViewModel> { new EventGeneralInfoViewModel { ID = 1, EventName = "hello", EventDateStart = DateTime.Now, EventDateEnd = DateTime.Now } }, CreatedEvents = new List <EventGeneralInfoViewModel> { new EventGeneralInfoViewModel { ID = 2, EventName = "world", EventDateStart = DateTime.Now, EventDateEnd = DateTime.Now } }, VisitedEvents = new List <EventGeneralInfoViewModel> { new EventGeneralInfoViewModel { ID = 3, EventName = "!!!", EventDateStart = DateTime.Now, EventDateEnd = DateTime.Now } } }; return(model); }