public async Task <IActionResult> Edit(EditUserViewModel model) { if (string.IsNullOrEmpty(model.Id)) { return(JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#id")); } if (string.IsNullOrEmpty(model.FullName)) { return(JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#fullName")); } // IF we create new account we have to check Password and whether user exists if (!string.IsNullOrEmpty(model.Create)) { if (await UsersRepository.UserExists(model.Id)) { return(JsonFailResult(Phrases.UserExists, "#id")); } if (string.IsNullOrEmpty(model.Password)) { return(JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#password")); } await UsersRepository.CreateAsync(model, model.Password); await _userCacheService.UpdateUsersAndRoles(); } else { await UsersRepository.UpdateAsync(model); } return(JsonRequestResult("#pamain", Url.Action("Index"))); }
private void FillUsersCache(IApplicationBuilder app) { IUserCacheService userCacheService = app.ApplicationServices.GetService <IUserCacheService>(); userCacheService.UpdateUsersAndRoles().Wait(); }