Esempio n. 1
0
        // 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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 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());
 }
Esempio n. 4
0
        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));
            }
        }