public INotificationService GetService(NotificationSourceType type)
        {
            switch (type)
            {
            case NotificationSourceType.Email:
                return(new EmailNotificationService(_appSettings));

                break;
            }

            throw new NotImplementedException("Notification service does not exist");
        }
        public ServiceResult ChangePassword(string model, string password, NotificationSourceType type)
        {
            var result = new ServiceResult();

            try
            {
                User user = null;

                switch (type)
                {
                case NotificationSourceType.Email:
                    user = _uow.Repository <User>().FindUserByEmail(model);
                    break;

                default:
                    throw new ArgumentException();
                }

                if (user == null)
                {
                    result.Status       = ResultStatus.Error;
                    result.ErrorMessage = "User does not exist";
                    return(result);
                }

                user.Password = _hashingService.Hash(password);

                _uow.SaveChanges();

                result.Status = ResultStatus.Success;
            }
            catch (Exception e)
            {
                result.Status = ResultStatus.ServerError;
            }

            return(result);
        }
        public ServiceResult ForgotPassword(string model, NotificationSourceType type)
        {
            var result = new ServiceResult();
            NotificationMessage message = null;
            User user = null;

            try
            {
                if (type == NotificationSourceType.Inner)
                {
                    throw new ArgumentException("Inner notification cannot be used for restoring password");
                }

                var notification = _notificationServiceFactory.GetService(type);

                if (!notification.CanUse)
                {
                    throw new ArgumentException($"Service {nameof(notification)} cannot be use");
                }

                switch (type)
                {
                case NotificationSourceType.Email:

                    user = _uow.Repository <User>().FindUserByEmail(model);

                    if (user == null)
                    {
                        result.Status       = ResultStatus.Error;
                        result.ErrorMessage = "User does not exist";
                        return(result);
                    }

                    var relativeUrl = $"/restore-passoword/{_hashingService.Hash("SomeText")}";

                    message = new NotificationMessage
                    {
                        Title = "Restoring password",
                        To    = model,
                        Body  = $"Click a link below {_httpContext.HttpContext.GetHostBaseUrl(relativeUrl)}",
                        From  = _settings.EmailSettings.MAIL_SMTP_LOGIN
                    };
                    break;

                default:
                    throw new ArgumentException();
                }

                result = notification.Send(message);

                if (!result.IsSuccessed)
                {
                    return(result);
                }

                user.RestorePassowordType = type;
                user.PasswordReseted      = true;
                _uow.SaveChanges();

                result.Status = ResultStatus.Success;
            }
            catch (Exception e)
            {
                result.Status = ResultStatus.ServerError;
            }

            return(result);
        }