public async Task <IActionResult> DeleteUser([FromForm] UserViewModel userViewModel) { await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "0"); User user = new User(); user.UserId = userViewModel.UserId; user.ModifiedBy = 5; await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "40"); await this._adminService.DeleteUser(user); dynamic ajaxReturn = new JObject(); ajaxReturn.Status = "Success"; ajaxReturn.UserId = userViewModel.UserId; ajaxReturn.GetGoodJobVerb = GoodWorkVerbs.GetGoodJobVerb(); ajaxReturn.Message = "UserName" + " - user sucessfully delete from application."; await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "100"); return(this.Json(ajaxReturn)); }
public async Task <IActionResult> EditUser([FromForm] UserViewModel userViewModel) { await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "0"); User user = new User(); user = this._mapper.Map <User>(userViewModel); await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "40"); await this._adminService.EditUser(user); await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "80"); dynamic ajaxReturn = new JObject(); ajaxReturn.Status = "Success"; ajaxReturn.UserId = userViewModel.UserId; ajaxReturn.GetGoodJobVerb = GoodWorkVerbs.GetGoodJobVerb(); ajaxReturn.Message = "UserName" + " - user details updated successfully"; await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "100"); return(this.Json(ajaxReturn)); }
public async Task <IActionResult> AddRolesToUser( [FromForm] List <RoleAssetMappingViewModel> roleAssetMappingViewModels, long userId) { if (!roleAssetMappingViewModels.Any(a => a.IsActive == true)) { dynamic ajaxValidatationErrorReturn = new JObject(); ajaxValidatationErrorReturn.Status = "ValidatationError"; ajaxValidatationErrorReturn.Message = "Please select at least one role."; return(this.Json(ajaxValidatationErrorReturn)); } roleAssetMappingViewModels = roleAssetMappingViewModels.Where(w => w.IsActive == true).ToList(); List <RoleAssetMapping> roleAssetMappings = new List <RoleAssetMapping>(); roleAssetMappings = this._mapper.Map <List <RoleAssetMapping> >(roleAssetMappingViewModels); await this._adminService.AddRolesToUser(roleAssetMappings, userId, 123); dynamic ajaxReturn = new JObject(); ajaxReturn.Status = "Success"; ajaxReturn.UserId = userId; ajaxReturn.GetGoodJobVerb = GoodWorkVerbs.GetGoodJobVerb(); ajaxReturn.Message = "Roles has been added to users. " + "Please click next to view user's summary"; return(this.Json(ajaxReturn)); }
public async Task <IActionResult> AddUser([FromForm] UserViewModel userViewModel) { await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "0"); if (!ModelState.IsValid) { await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "100"); return(await Task.Run(() => this.PartialView("_AddUser1", userViewModel))); } await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "20"); User user = new User(); user = this._mapper.Map <User>(userViewModel); await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "40"); var userId = await this._adminService.AddUser(user); await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "80"); dynamic ajaxReturn = new JObject(); ajaxReturn.Status = "Success"; ajaxReturn.UserId = userId; ajaxReturn.GetGoodJobVerb = GoodWorkVerbs.GetGoodJobVerb(); ajaxReturn.Message = userViewModel.UserName + " - user sucessfully created." + " Now you can setup application roles"; await this._anonymousHubContext.Clients. Client(userViewModel.ConnectionId).SendAsync("progressBarUpdate", "100"); return(this.Json(ajaxReturn)); }