public async Task <IActionResult> CompanyRegister([FromBody] RegisterCompanyModel model)
        {
            CompanyRegisterOutput output = new CompanyRegisterOutput();

            if (model.IsValid)
            {
                RegisterCompany registerUser = new RegisterCompany(_signInManager, _userManager, _configuration);
                output = await registerUser.UserRegister(model);

                return(Ok(output));
            }
            else
            {
                output.ErrorCode        = CompanyRegisterOutput.ErrorCodes.NullRequest;
                output.ErrorDescription = "Model is not valid";
                output.Token            = null;

                return(BadRequest(output));
            }
        }
        public async Task <CompanyRegisterOutput> UserRegister(RegisterCompanyModel model)
        {
            CompanyRegisterOutput output = new CompanyRegisterOutput();

            if (model == null)
            {
                Log(ErrorCodes.NullRequest, "Model is Null", model);

                output.ErrorCode        = CompanyRegisterOutput.ErrorCodes.NullRequest;
                output.ErrorDescription = "Model is not valid";
                output.Token            = null;
                return(output);
            }

            try
            {
                var user = new ApplicationUser
                {
                    Email                = model.Email,
                    UserName             = model.Email,
                    IsCompany            = true,
                    EmailConfirmed       = true,
                    PhoneNumber          = model.Mobile,
                    PhoneNumberConfirmed = false,
                    CreatedDate          = DateTime.Now,
                    LastModifiedDate     = DateTime.Now,
                    LastLoginDate        = DateTime.Now,
                    RoleId               = Guid.Parse("DB5159FA-D585-4FEE-87B1-D9290D515DFB"),
                    LanguageId           = Guid.Parse("5046A00B-D915-48A1-8CCF-5E5DFAB934FB")
                };

                var result = await _userManager.CreateAsync(user, model.Password);

                if (!result.Succeeded)
                {
                    Log(ErrorCodes.ServiceException, "User failed to register", model);


                    StringBuilder errorList = new StringBuilder();
                    result.Errors.ToList().ForEach(e => errorList.Append(e.Description + Environment.NewLine));

                    output.ErrorCode        = CompanyRegisterOutput.ErrorCodes.ServiceException;
                    output.ErrorDescription = errorList.ToString();
                    output.Token            = null;

                    return(output);
                }
                else
                {
                    var registeredUser = await _userManager.FindByEmailAsync(model.Email);

                    if (registeredUser != null)
                    {
                        Log(ErrorCodes.Success, "User Registered Successfully", model);

                        GenerateToken    generateToken = new GenerateToken(_configuration);
                        JwtSecurityToken token         = generateToken.GenerateTokenJWT(user.Id, user.Email);

                        output.ErrorCode        = CompanyRegisterOutput.ErrorCodes.Success;
                        output.ErrorDescription = "Registered Successfully";
                        output.Token            = new JwtSecurityTokenHandler().WriteToken(token);

                        return(output);
                    }
                    else
                    {
                        Log(ErrorCodes.NullResponse, "User not found", model);

                        output.ErrorCode        = CompanyRegisterOutput.ErrorCodes.NullResponse;
                        output.ErrorDescription = "Failed to create user";
                        output.Token            = null;

                        return(output);
                    }
                }
            }
            catch (Exception exp)
            {
                Log(ErrorCodes.MethodException, exp.ToString(), model);

                output.ErrorCode        = CompanyRegisterOutput.ErrorCodes.MethodException;
                output.ErrorDescription = "UserLogin through exception";
                output.Token            = null;

                return(output);
            }
        }