public async Task <IActionResult> UpdateUser(string id, [FromBody] AppUserResource appuserResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var appuser = await repository.GetUserWithAddress(id); if (appuser == null) { return(NotFound()); } mapper.Map(appuserResource, appuser); await unitOfWork.CompleteAsync(); return(Ok(mapper.Map <AppUser, AppUserResource>(appuser))); }
public async Task <Object> Register([FromBody] AppUserResource model) { model.Role = "Customer"; var appUser = this.mapper.Map <AppUserResource, AppUser>(model); try { var result = await this.userManager.CreateAsync(appUser, model.Password); await this.userManager.AddToRoleAsync(appUser, model.Role); return(Ok(result)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> CreateUser([FromBody] AppUserResource appuserResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var appuser = mapper.Map <AppUserResource, AppUser>(appuserResource); try { var result = await this.userManager.CreateAsync(appuser, appuserResource.Password); return(Ok(result)); } catch (Exception ex) { throw ex; } }