// GET: Events public ActionResult Index() { var repo = new Repository <Event>(); var events = repo.GetAll; if (CheckUserRole.IsUserInRole(User.Identity.GetUserId(), "EventOrganizer")) { events = repo.GetAll.Where(x => x.UserId == User.Identity.GetUserId()); } var model = Mapper.Map <IEnumerable <Event>, IEnumerable <EventViewModel> >(events); return(View(model)); }
public ActionResult Create(Guid offerid) { var model = new CreateUserApplicableOffersViewModel(); model.OfferId = offerid; var usersList = new List <SelectListItem>(); UserManager.Users.ForEach(x => { if (CheckUserRole.IsUserInRole(x.Id, "User")) { usersList.Add(new SelectListItem { Text = x.FirstName + " " + x.LastName, Value = x.Id }); } }); model.UsersList = usersList; return(View(model)); }
public ActionResult Index() { if (User.Identity.IsAuthenticated) { if (CheckUserRole.IsUserInRole(User.Identity.GetUserId(), "Admin")) { return(RedirectToAction("Admin")); } else if (CheckUserRole.IsUserInRole(User.Identity.GetUserId(), "EventOrganizer")) { return(RedirectToAction("Organizer")); } else if (CheckUserRole.IsUserInRole(User.Identity.GetUserId(), "User")) { return(RedirectToAction("UserHome")); } } return(View()); }
public ActionResult Edit(Guid id) { using (var repo = new Repository <UserApplicableToOffer>()) { var offer = repo.GetById(id); var model = Mapper.Map <UserApplicableToOffer, EditUserApplicableOffersViewModel>(offer); var usersList = new List <SelectListItem>(); UserManager.Users.ForEach(x => { if (CheckUserRole.IsUserInRole(x.Id, "User")) { usersList.Add(new SelectListItem { Text = x.FirstName + " " + x.LastName, Value = x.Id }); } }); model.UsersList = usersList; return(View(model)); } }