public IActionResult AddUser([FromBody] User userToAdd) { var wasUserAdded = _loginRepository.AddUser(userToAdd); if (!wasUserAdded) { return(Forbid()); } return(Ok(null)); }
public async Task <IActionResult> Create([FromBody] Users model) { string message; logger.LogDebug("Validating user"); if (!ModelState.IsValid) { logger.LogError("Invalid user"); message = "Invalid user"; return(BadRequest(message)); } logger.LogDebug("User {0} is valid", model.Email); try { logger.LogDebug("Adding user"); var userId = await loginRepository.AddUser(model); if (userId > 0) { logger.LogInformation("User {0} added succesfully", model.Email); return(Ok(userId)); } else { logger.LogError("Error adding the user {0}", model.Email); message = "Error adding the user"; } } catch (Exception e) { logger.LogError("Error adding user: {0}", e.Message); message = "Error adding the user"; } return(BadRequest(message)); }
public string AddNewUser([FromBody] UserCredentials user) { _repository.AddUser(user); return("Success"); }