public async Task <bool> RegisterCommonUser(RegisterCommonUserRequest request) { var copier = new ClassValueCopier(); //check for used existance var result = await _usersCollection.CheckUserExistance(request.EmailId); if (!result) { throw new Exception("User Exists"); } //if no create user Users newUser = copier.ConvertAndCopy <Users, RegisterCommonUserRequest>(request); newUser.Role = "CommonUser"; newUser.IsCommonUser = true; //push to DB newUser = await _usersCollection.RegisterUserAsync(newUser); //Send the userDetails to all the service await PublishUserCredentialAsync(newUser); return(true); }
public async Task <IActionResult> RegisterCommonUser(RegisterCommonUserRequest request) { ActionResponse response; try { bool result = await _businessLogic.RegisterCommonUser(request); response = (result) ? new ActionResponse(StatusCodes.Status200OK) : new ActionResponse(StatusCodes.Status422UnprocessableEntity); } catch (Exception ex) { response = new ActionResponse(StatusCodes.Status500InternalServerError); response.StatusDescription += ex.Message.ToString(); } return(StatusCode(response.StatusCode, response)); }