Ejemplo n.º 1
0
        public ActionResult Create(ContentManager contentManager)
        {
            if (ModelState.IsValid)
            {
                if (!Roles.RoleExists(Constants.ROLE_CONTENT_MANAGER))
                    Roles.CreateRole(Constants.ROLE_CONTENT_MANAGER);

                var status = MembershipCreateStatus.UserRejected;

                if (Membership.GetUser(contentManager.Login) == null)
                    Membership.CreateUser(contentManager.Login, contentManager.Password, "*****@*****.**", "Capital of Russia", "Moscow", true, out status);
                else
                {
                    ViewBag.ErrorMessage = "Пользователь с таким логином существует.";
                    return View(contentManager);
                }

                if (status == MembershipCreateStatus.Success)
                {
                    var profile = new UserProfile(contentManager.Login)
                                      {
                                          FirstName = contentManager.FirstName,
                                          MiddleName = contentManager.MiddleName,
                                          LastName = contentManager.LastName
                                      };
                    profile.Save();

                    if (!Roles.IsUserInRole(contentManager.Login, Constants.ROLE_CONTENT_MANAGER))
                        Roles.AddUserToRole(contentManager.Login, Constants.ROLE_CONTENT_MANAGER);
                }

                return RedirectToAction("Index");
            }
            else return View(contentManager);
        }
Ejemplo n.º 2
0
 public ActionResult Edit(FormCollection collection)
 {
     var profile = new UserProfile(User.Identity.Name);
     UpdateModel(profile, collection);
     profile.Save();
     return RedirectToAction("IndexPersonal");
 }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            var contentManagers = new List<ContentManager>();

            if (Roles.RoleExists(Constants.ROLE_CONTENT_MANAGER))
            {
                string[] users = Roles.GetUsersInRole(Constants.ROLE_CONTENT_MANAGER);

                foreach (string username in users)
                {
                    var profile = new UserProfile(username);
                    var contentManager = new ContentManager() { Login = username, Password = string.Empty, Repeat = string.Empty, FirstName = profile.FirstName, MiddleName = profile.MiddleName, LastName = profile.LastName };
                    contentManagers.Add(contentManager);
                }
            }

            contentManagers = contentManagers.AsQueryable().OrderBy(item => item.LastName).ToList();
            return View(contentManagers);
        }
Ejemplo n.º 4
0
 public ActionResult Edit()
 {
     var profile = new UserProfile(User.Identity.Name);
     return View(profile);
 }
Ejemplo n.º 5
0
 public ActionResult IndexPersonal()
 {
     var profile = new UserProfile(User.Identity.Name);
     return View(profile);
 }