コード例 #1
0
        public CommandResult Handle(SendTellAFriendMailCommand command)
        {
            var message = TellAFriendMailComposer.ComposeMail(command);

            _mailClient.SendMail(message);

            return(new CommandSuccessResult());
        }
コード例 #2
0
        public IActionResult Post(UserRegistration user)
        {
            IActionResult result = BadRequest();

            // TODO: send the proper explanation for bad-request.
            user.Nickname = DbTools.SanitizeString(user.Nickname);
            user.Email    = DbTools.SanitizeString(user.Email);

            if (ModelState.IsValid &&
                !userRepository.IfNicknameExists(user.Nickname) &&
                !userRepository.IfEmailExists(user.Email))
            {
                user.Password = DbTools.SanitizeString(user.Password);
                if (user.Provider != null && socialAuth.getCheckAuth(user.Provider, user.Password, user.Nickname))
                {
                    if (user.Password.Length > 300)
                    {
                        user.Password = user.Password.Substring(0, 300);
                    }
                    result = Ok(userRepository.Create(user));
                }
                else if (user.Provider == null)
                {
                    var verify = new Verification();
                    verify.Email         = user.Email;
                    verify.Token         = Guid.NewGuid().ToString();
                    user.Email           = verify.Token;
                    verify.EndVerifyDate = DateTime.Now.AddDays(3);

                    userRepository.Create(verify);
                    cleaner.TryToStart();
                    smtpClient.SendMail(verify.Email, "Register confirmation", "", verify.Token);
                    result = Ok(userRepository.Create(user));
                }
            }

            return(result);
        }
コード例 #3
0
        public bool SendAlert(string customerReference, string message)
        {
            var customer = _customerRepository.GetCustomer(customerReference);

            return(_smtpClient.SendMail(customer?.Email, message));
        }