/// <summary>
        /// Sends an email to the new user
        /// </summary>
        /// <param name="user">The new user model</param>
        /// <returns></returns>
        public Response <UserModel> SendNewUserEmail(UserModel user)
        {
            //Get email template for reset password
            var messageTemplate = _messageTemplateDataProvider.GetMessageTemplate((int)TemplateType.NewUserNotification);
            var emailMessage    = PrepareNewUserEmailMessage(messageTemplate.DataItems.FirstOrDefault(), user);
            var response        = new Response <UserModel>();

            try
            {
                string error = string.Empty;
                if (_emailService.Send(emailMessage, out error) == false)
                {
                    _logger.Error(new Exception(error));
                    response.ResultCode    = 1;
                    response.ResultMessage = error;
                }
                return(response);
            }
            catch (Exception exc)
            {
                _logger.Error(exc);
                response.ResultCode    = 1;
                response.ResultMessage = exc.Message;
            }

            return(response);
        }
        /// <summary>
        /// Sends the reset link.usp_ValidateServerIPAddress
        /// </summary>
        /// <param name="email">The email.</param>
        /// <param name="requestorIPAddress">The requestor ip address.</param>
        /// <returns></returns>
        public Response <ResetPasswordModel> SendResetLink(string email, string requestorIPAddress)
        {
            //Get email template for reset password
            var messageTemplate = messageTemplateDataProvider.GetMessageTemplate((int)TemplateType.ResetPasswordInitiation);
            var response        = new Response <ResetPasswordModel>();

            var users = adminDataProvider.GetUserByEmail(email);

            if (users != null && users.DataItems != null && users.DataItems.Count > 0)
            {
                if (users.DataItems[0].IsActive == false)
                {
                    response.ResultCode    = 1;
                    response.ResultMessage = "Unable to reset password because user is inactive";
                }
                else
                if (users.DataItems[0].ADFlag == false)     // ADFlag cannot be null
                {
                    var resetIdentifier = Guid.NewGuid();
                    var user            = users.DataItems.FirstOrDefault();
                    if (user != null)
                    {
                        var createLinkResponse = CreateResetPasswordLink(user.UserID, requestorIPAddress, resetIdentifier);
                        if (createLinkResponse.ResultCode == 0)
                        {
                            var emailMessage = PrepareResetPasswordEmailMessage(user, messageTemplate.DataItems.FirstOrDefault(), email, resetIdentifier);
                            try
                            {
                                string error = string.Empty;
                                if (emailService.Send(emailMessage, out error) == false)
                                {
                                    logger.Error(new Exception(error));
                                    response.ResultCode    = 1;
                                    response.ResultMessage = error;
                                }
                                return(response);
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex);
                                response.ResultCode    = 1;
                                response.ResultMessage = ex.Message;
                            }
                        }
                        else
                        {
                            response.ResultCode    = 1;
                            response.ResultMessage = "Unable to create reset link.";
                        }
                    }
                }
                else
                {
                    response.DataItems = new List <ResetPasswordModel> {
                        new ResetPasswordModel {
                            ADFlag = users.DataItems[0].ADFlag, ADUserPasswordResetMessage = users.DataItems[0].ADUserPasswordResetMessage
                        }
                    };
                }
            }
            else
            {
                response.ResultCode    = 1;
                response.ResultMessage = "Email is not defined in the axis system.";
            }
            return(response);
        }