public async Task <IActionResult> RegisterAdminUser(RegisterAdminUserRequest request)
        {
            ActionResponse response;

            try
            {
                bool result = await _businessLogic.RegisterAdminUser(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));
        }
Ejemplo n.º 2
0
        public async Task <bool> RegisterAdminUser(RegisterAdminUserRequest request)
        {
            var copier = new ClassValueCopier();
            //check for used existance
            var result = await _usersCollection.CheckUserExistance(request.EmailId);

            if (!result)
            {
                throw new Exception("User Exists");
            }

            Users newUser = copier.ConvertAndCopy <Users, RegisterAdminUserRequest>(request);

            newUser.IsCommonUser = false;
            newUser.Password     = newUser.BadgeId;
            newUser = await _usersCollection.RegisterUserAsync(newUser);

            await PublishUserCredentialAsync(newUser);

            return(true);
        }