public async Task <ActionResult> RegisterAsync([FromBody] RegisterValidationModel model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     if (!await _storage.TryAddUserAsync(model))
     {
         return(Conflict());
     }
     return(Ok());
 }
示例#2
0
 public async Task <bool> TryAddUserAsync(RegisterValidationModel model)
 {
     return(await Task.Run(async() =>
     {
         if (model == null)
         {
             throw new ArgumentNullException(nameof(model));
         }
         var user = new User(model.Login, model.Password);
         if (await _dbContext.Users.FirstOrDefaultAsync(u => u.Login == user.Login) is { })
         {
             return false;
         }
         _dbContext.Users.Add(user);
         await _dbContext.SaveChangesAsync();
         return true;
     }));
示例#3
0
 public IActionResult Register([FromBody] RegisterValidationModel model)
 {
     throw new NotImplementedException();
 }