当前位置: 首页>>代码示例>>C#>>正文


C# EditUserViewModel类代码示例

本文整理汇总了C#中EditUserViewModel的典型用法代码示例。如果您正苦于以下问题:C# EditUserViewModel类的具体用法?C# EditUserViewModel怎么用?C# EditUserViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EditUserViewModel类属于命名空间,在下文中一共展示了EditUserViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Edit

        public async Task<ActionResult> Edit(EditUserViewModel model)
        {
            var Db = new ApplicationDbContext();
            var user = Db.Users.First(u => u.UserName == model.UserName);
            if (ModelState.IsValid)
            {
                model.PhotoUrl = Utils.SavePhotoFileToDisk(model.Photo, this, user.PhotoUrl, model.IsNoPhotoChecked);
                user.PhotoUrl = model.PhotoUrl;

                // Update the user data:
                user.FirstName = model.FirstName;
                user.LastName = model.LastName;
                user.Email = model.Email;
                Db.Entry(user).State = System.Data.Entity.EntityState.Modified;
                await Db.SaveChangesAsync();

                if (HttpContext.User.IsInRole("Admin"))
                {
                    return RedirectToAction("Index");
                }
                else
                {
                    return RedirectToAction("Edit", new { id = user.UserName, Message = ManageMessageId.RegisterSuccess });
                }
            }
            model.PhotoUrl = user.PhotoUrl;
            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:jalvarez54,项目名称:NorthWind54,代码行数:29,代码来源:AccountController.cs

示例2: Edit

 public ActionResult Edit(string id, ManageMessageId? Message = null)
 {
     var Db = new ApplicationDbContext();
     var user = Db.Users.First(u => u.UserName == id);
     var model = new EditUserViewModel(user);
     ViewBag.MessageId = Message;
     return View(model);
 }
开发者ID:futurify-tainguyen,项目名称:VsmartSell-DashBoard,代码行数:8,代码来源:AccountController.cs

示例3: EditUser

        public ActionResult EditUser(string name, ManageMessageId? Message = null)
        {
            var user = this.ApplicationDbContext.Users.First(u => u.UserName == name);
            var model = new EditUserViewModel(user);

            ViewBag.MessageId = Message;
            ViewBag.Title = "Edit User";

            return View(model);
        }
开发者ID:W1R3D-Code,项目名称:TheExordium,代码行数:10,代码来源:UserAdministrationController.cs

示例4: SaveUser

        /// <summary>
        /// Saves the user.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>Json status result.</returns>
        public ActionResult SaveUser(EditUserViewModel model)
        {
            var response = GetCommand<SaveUserCommand>().ExecuteCommand(model);
            if (response != null)
            {
                Messages.AddSuccess(UsersGlobalization.SaveUser_CreatedSuccessfully_Message);
                return Json(new WireJson { Success = true, Data = response });
            }

            return Json(new WireJson { Success = false });
        }
开发者ID:tkirda,项目名称:BetterCMS,代码行数:16,代码来源:UserController.cs

示例5: Delete

 public ActionResult Delete(string id = null)
 {
     var Db = new ApplicationDbContext();
     var user = Db.Users.First(u => u.UserName == id);
     var model = new EditUserViewModel(user);
     if (user == null)
     {
         return HttpNotFound();
     }
     return View(model);
 }
开发者ID:futurify-tainguyen,项目名称:VsmartSell-DashBoard,代码行数:11,代码来源:AccountController.cs

示例6: Index

 /// <summary>
 /// Returns a view model to show all accounts.
 /// </summary>
 /// <returns></returns>
 public ActionResult Index()
 {
     var Db = new ApplicationDbContext();
     var users = Db.Users;
     var model = new List<EditUserViewModel>();
     foreach (var user in users)
     {
         var u = new EditUserViewModel(user);
         model.Add(u);
     }
     return View(model);
 }
开发者ID:jioe,项目名称:appverse-net,代码行数:16,代码来源:AccountsController.cs

示例7: Index

 public ActionResult Index()
 {
     //var users = UserManager.Users.Cast<List<EditUserViewModel>>().ToList();
     var db = new ApplicationDbContext();
     var users = db.Users;
     var model = new List<EditUserViewModel>();
     foreach (var user in users)
     {
         var u = new EditUserViewModel(user);
         model.Add(u);
     }
     return View(model);
 }
开发者ID:Evanjs,项目名称:Demo_NMM.Basic,代码行数:13,代码来源:AccountController.cs

示例8: EditUser

        public async Task<IActionResult> EditUser(EditUserViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            //Skill associations
            var user = GetUser(viewModel.UserId);
            user.AssociatedSkills.RemoveAll(usk => viewModel.AssociatedSkills == null || !viewModel.AssociatedSkills.Any(msk => msk.SkillId == usk.SkillId));

            if (viewModel.AssociatedSkills != null)
            {
                user.AssociatedSkills.AddRange(viewModel.AssociatedSkills.Where(msk => !user.AssociatedSkills.Any(usk => usk.SkillId == msk.SkillId)));
            }

            if (user.AssociatedSkills != null && user.AssociatedSkills.Count > 0)
            {
                user.AssociatedSkills.ForEach(usk => usk.UserId = user.Id);
            }

            await _mediator.SendAsync(new UpdateUser { User = user });

            var organizationAdminClaim = new Claim(Security.ClaimTypes.UserType, "OrgAdmin");
            if (viewModel.IsOrganizationAdmin)
            {
                //add organization admin claim
                var result = await _userManager.AddClaimAsync(user, organizationAdminClaim);
                if (result.Succeeded)
                {
                    //mgmccarthy: there is no Login action method on the AdminController. The only login method I could find is on the AccountController. Not too sure what to do here
                    var callbackUrl = Url.Action(new UrlActionContext { Action = "Login", Controller = "Admin", Values = new { Email = user.Email }, Protocol = HttpContext.Request.Scheme });
                    await _mediator.SendAsync(new SendAccountApprovalEmail { Email = user.Email, CallbackUrl = callbackUrl });
                }
                else
                {
                    return Redirect("Error");
                }
            }
            else if (user.IsUserType(UserType.OrgAdmin))
            {
                //remove organization admin claim
                var result = await _userManager.RemoveClaimAsync(user, organizationAdminClaim);
                if (!result.Succeeded)
                {
                    return Redirect("Error");
                }
            }

            return RedirectToAction(nameof(Index));
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:51,代码来源:SiteAdminController.cs

示例9: Index

        public ActionResult Index()
        {
            var companies = companyService.GetCompanies();
            var roles = roleService.GetRoles();
            EditUserViewModel editUser = new EditUserViewModel()
            {
                Roles = roles.ToList(),
                CompanyList = companies.ToList()
            };
            ViewData["companies"] = companies;
            ViewData["EditUser"] = editUser;
            return View();

        }
开发者ID:hoangec,项目名称:ECHRMS,代码行数:14,代码来源:AccountController.cs

示例10: Edit

        public ActionResult Edit(string id, ManageMessageId? Message = null)
        {
            var Db = new ApplicationDbContext();
            var user = Db.Users.First(u => u.UserName == id);
            var model = new EditUserViewModel(user);
            ViewBag.MessageId = Message;
            
            var userprefer = Db.UserPreferences.Where(a => a.UserName == id).Select(x=> new {x.SchoolRefID,x.AcademicYearRefID}).FirstOrDefault();
            
            ViewBag.SchoolID = new SelectList(Db.Schools.AsNoTracking().Select(x => new { x.SchoolID, x.SchoolName }), "SchoolID", "SchoolName",userprefer.SchoolRefID);
            ViewBag.AcademicYearID = new SelectList(Db.AcademicYears.AsNoTracking().Where(a => a.SchoolRefID ==userprefer.SchoolRefID).Select(x => new { x.AcademicYearID, x.DisplayYear }), "AcademicYearID", "DisplayYear",userprefer.AcademicYearRefID);

            return View(model);
        }
开发者ID:jsraffi,项目名称:osismodelWeb,代码行数:14,代码来源:AccountController.cs

示例11: Index

        public ActionResult Index(string sortOrder, string searchString)
        {
            ViewBag.UsernameSortParam = String.IsNullOrEmpty(sortOrder) ? "username_asc" : "";
            ViewBag.NameSortParam = sortOrder == "first_asc" ? "first_desc" : "first_asc";
            ViewBag.LastSortParam = sortOrder == "last_asc" ? "last_desc" : "last_asc";

            var db = new ApplicationDbContext();
            var users = from u in db.Users
                        where u.Status != ApplicationUser.AccountStatus.Disabled
                        select u;

            if (!String.IsNullOrEmpty(searchString))
            {
                users = users.Where(u => u.LastName.Contains(searchString)
                                       || u.FirstName.Contains(searchString)
                                       && u.Status != ApplicationUser.AccountStatus.Disabled);
            }
            switch (sortOrder)
            {
                case "username_asc":
                    users = users.OrderBy(u => u.UserName);
                    break;
                case "first_desc":
                    users = users.OrderByDescending(u => u.FirstName);
                    break;
                case "last_desc":
                    users = users.OrderByDescending(u => u.LastName);
                    break;
                case "first_asc":
                    users = users.OrderBy(u => u.FirstName);
                    break;
                case "last_asc":
                    users = users.OrderBy(u => u.LastName);
                    break;
            }

            var model = new System.Collections.Generic.List<EditUserViewModel>();

            foreach (var user in users)
            {
                var u = new EditUserViewModel(user);
                model.Add(u);
            }
            return View(model);
        }
开发者ID:Buchan28,项目名称:PLM,代码行数:45,代码来源:AccountController.cs

示例12: Index

        public ActionResult Index(string userrole = null)
        {
            List<ApplicationUser> users;
            if (userrole != null)
            {
                users = _accountService.GetUsersByRole(userrole);
            }
            else
            {
                users = _accountService.GetAllUsers();
            }

            var model = new List<EditUserViewModel>();
            foreach (ApplicationUser user in users)
            {
                var u = new EditUserViewModel(user);
                model.Add(u);
            }
            return View(model);
        }
开发者ID:khoaht,项目名称:AngularJSDemo,代码行数:20,代码来源:AccountController.cs

示例13: Update

        public ActionResult Update([DataSourceRequest]DataSourceRequest request, EditUserViewModel user)
        {
            if (!ModelState.IsValid)
            {
                return this.View();
            }

            var currentUser = this.UserService.GetById(user.Id)
                                              .FirstOrDefault();

            if (currentUser == null)
            {
                return this.View();
            }

            currentUser.FirstName = user.FirstName;
            currentUser.LastName = user.LastName;
            currentUser.Email = user.Email;
            currentUser.UserName = user.UserName;

            this.UserService.UpdateUser(currentUser);
            return Json(new[] { user }.ToDataSourceResult(request, ModelState));
        }
开发者ID:zhenyaracheva,项目名称:RoutExtreme,代码行数:23,代码来源:UserController.cs

示例14: Edit

        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ViewBag.ALUMNOS = new SelectList(new PersonasRepository().GetAlumnos(), "ID", "PERSONA_NOMBRE_COMPLETO");
            ApplicationUser user = _repo.GetUser(id);

            var roleStore = new RoleStore<IdentityRole>(context);
            var roleManager = new RoleManager<IdentityRole>(roleStore);
            var userRoles = UserManager.GetRoles(id);
            ViewBag.USER_ROLES = roleStore.Roles.ToList().Select(x => new SelectListItem()
            {
                Selected = userRoles.Contains(x.Name),
                Text = x.Name,
                Value = x.Name
            });
            EditUserViewModel vm = new EditUserViewModel
            {
                Email = user.Email,
                UserName = user.UserName,
                USER_PERSONA_ID = user.USER_PERSONA_ID != null ? user.USER_PERSONA_ID.Value : 0,
            };

            return View(vm);
        }
开发者ID:nahue,项目名称:Terciario,代码行数:27,代码来源:UsuariosController.cs

示例15: CreateUser

 public ActionResult CreateUser()
 {
     var model = new EditUserViewModel { IsNewUser = true };
     return PartialView("EditUser", model);
 }
开发者ID:LokeSonne,项目名称:ApplicationWithUserManagement,代码行数:5,代码来源:UserManagementController.cs


注:本文中的EditUserViewModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。