public AuthenticationViewModel() { _authenticationService = new AuthenticationService(); LoginCommand = new RelayCommand(CheckCredentials, CanAct); CreateModeCommand = new RelayCommand <string>(SetCreateMode); SaveAccountCommand = new RelayCommand(SaveAccount, CanAct); User = new EditableUser(); User.ErrorsChanged += RaiseCanExecuteChanged; }
public IActionResult Edit([FromBody] EditableUser user) { if (!CanEdit(user.Id)) { return(Forbid()); } (bool result, string message) = _usersService.Edit(user); if (!result) { return(BadRequest(message)); } return(Ok()); }
public async Task <IActionResult> Unassign(EditableUser model, string returnUrl = null) { var roles = GetAllRoles(); model.ERoles = GetSelectListItems(roles); ViewData["ReturnUrl"] = returnUrl; var user = await _userManager.FindByEmailAsync(model.Email); await _userManager.RemoveFromRoleAsync(user, model.Role); model.Roles = await _userManager.GetRolesAsync(user); await EditRoles(user.Id); return(View("~/Views/Account/EditRoles.cshtml")); }
public async Task <IActionResult> Delete(string id) { if (id == null) { return(NotFound()); } var model = new EditableUser(); var user = await _userManager.FindByIdAsync(id); model.UserName = user.UserName; model.Email = user.Email; model.Roles = await _userManager.GetRolesAsync(user); if (model == null) { return(NotFound()); } return(View(model)); }
public AuthUser(EditableUser mutableUser) { user = mutableUser; }
public UsersForm() { InitializeComponent(); editableUser = new EditableUser(this); ReloadListView(); }
public ActionResult Save(int id) { //Create a new instance of the EditableProduct class and set its ProductID property. EditableUser user = new EditableUser { Id = id }; //Perform model binding (fill the product properties and validate it). if (TryUpdateModel(user)) { var u = db.Users.Where(e => e.Id == id).First(); if (user.Password != "●●●●●●●") { u.Password = Common.CalculateMD5Hash(user.Password); } u.EmailAddress = user.EmailAddress; u.IsActivated = user.IsActivated; u.RegistrationDate = user.RegistrationDate; u.Type = (int)user.Type; u.Username = user.Username; //The model is valid - update the product and redisplay the grid. db.Entry(u).State = System.Data.EntityState.Modified; db.SaveChanges(); //GridRouteValues() is an extension method which returns the //route values defining the grid state - current page, sort expression, filter etc. RouteValueDictionary routeValues = this.GridRouteValues(); // add the editing mode to the route values return RedirectToAction("Index", routeValues); } //The model is invalid - render the current view to show any validation errors return View("Index"); }