Пример #1
0
        public async Task <ActionResult> Edit(AddCrewViewModel b, string id)
        {
            var user = await UserManager.FindByIdAsync(id);

            await UserManager.IsLockedOutAsync(user.Id);

            await UserManager.SetLockoutEnabledAsync(user.Id, true);

            await UserManager.SetLockoutEndDateAsync(user.Id, DateTime.Today.AddDays(3));

            user.ban = true;

            return(RedirectToAction("Index_Member"));
        }
Пример #2
0
        // GET: Admin/Details/5
        public ActionResult Details(string id)
        {
            User             item = adminService.GetById(id);
            AddCrewViewModel t    = new AddCrewViewModel
            {
                Id        = item.Id,
                username  = item.UserName,
                Email     = item.Email,
                lastName  = item.lastName,
                FirstName = item.firstName,
                role      = item.role
            };

            return(View(t));
        }
Пример #3
0
        public ActionResult AddCrew(int showId)
        {
            if (!Request.IsAjaxRequest())
            {
                return(this.RedirectToAction(x => x.ShowDetails(showId)));
            }

            var people        = DatabaseSession.Query <Person>().ToList();
            var crewPositions = DatabaseSession.Query <ShowCrew>().Select(x => x.Position).Distinct().ToList();
            var viewModel     = new AddCrewViewModel(people, crewPositions)
            {
                POSTUrl = this.GetURL(x => x.AddCrew(showId)),
            };

            return(new ViewModelResult(viewModel));
        }
Пример #4
0
        public async Task <ActionResult> Create(AddCrewViewModel model, HttpPostedFileBase idFile)
        {
            if (ModelState.IsValid)
            {
                tagContext ctx  = new tagContext();
                string     link = Guid.NewGuid().ToString() +
                                  System.IO.Path.GetExtension(idFile.FileName);
                var uploadUrl = Server.MapPath("~/Content/img");
                idFile.SaveAs(Path.Combine(uploadUrl, link));
                model.image_link = "img\\" + link;
                var User = new User()
                {
                    UserName = model.username, Email = model.Email, firstName = model.FirstName, lastName = model.lastName, DTYPE = "Event_Organizer", role = "Event_Organizer", image_link = model.image_link
                };
                var roleManager = new RoleManager <Microsoft.AspNet.Identity.EntityFramework.IdentityRole>(new RoleStore <IdentityRole>(new tagContext()));
                if (!roleManager.RoleExists("Event_Organizer"))
                {
                    var Role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                    Role.Name = "Event_Organizer";
                    roleManager.Create(Role);
                }
                var result = await UserManager.CreateAsync(User, model.Password);

                var id = User.Id;
                System.Console.WriteLine(id);
                var role = UserManager.AddToRole(id, "Event_Organizer");
                var code = await UserManager.GenerateEmailConfirmationTokenAsync(User.Id);

                var callbackUrl = Url.Action(
                    "ConfirmEmail", "Account",
                    new { userId = User.Id, code = code },
                    protocol: Request.Url.Scheme);

                await UserManager.SendEmailAsync(User.Id,
                                                 "Confirm your account",
                                                 "Please confirm your account by clicking this link: <a href=\""
                                                 + callbackUrl + "\">link</a>");

                ctx.SaveChanges();
                return(RedirectToAction("Index_Event_Organizer"));
            }
            else
            {
                return(View());
            }
        }
Пример #5
0
        public ActionResult Index_Event_Organizer()
        {
            var crew = adminService.GetMany();
            List <AddCrewViewModel> users = new List <AddCrewViewModel>();

            foreach (var item in crew.Where(i => i.role == "Event_Organizer"))
            {
                AddCrewViewModel org = new AddCrewViewModel
                {
                    Id        = item.Id,
                    username  = item.UserName,
                    Email     = item.Email,
                    lastName  = item.lastName,
                    FirstName = item.firstName,
                    role      = item.role,
                };
                users.Add(org);
            }
            return(View(users));
        }