コード例 #1
0
        public JsonResult Register(User user, Customer customer)
        {
            HashingData hashingData = new HashingData();

            try
            {
                user.Role          = UserRole.Customer;
                user.Status        = Status.Inactive;
                customer.CreatedAt = DateTime.Now;
                customer.Status    = Status.Inactive;
                user.Customer      = customer;
                var key = hashingData.EncryptString(user.Username, AppSettingConstant.PasswordHash);
                user.ActiveMail = key;
                user.CreatedAt  = DateTime.Now;
                var result = _userService.Register(user);
                if (result)
                {
                    UserEmailConfirm model = new UserEmailConfirm(user.Email, hashingData.Encode(key), user.Username);
                    var body = ViewToString.RenderRazorViewToString(this, "ConfirmAccount", model);
                    Task.Factory.StartNew((() =>
                    {
                        SendEmail.Send(user.Email, body, "Confirm your email!");
                    }));
                    return(Json(new { status = true, url = "/register/ConfirmEmail" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(Json(new { status = false }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public static void SendKeyAdmin()
        {
            HashingData hashing    = new HashingData();
            var         key        = hashing.Encode(hashing.EncryptString(DateTime.UtcNow.ToString(), AppSettingConstant.PasswordHash));
            var         body       = key;
            var         emailAdmin = ConfigurationManager.AppSettings["mailadmin"];

            Task.Factory.StartNew((() =>
            {
                SendEmail.Send(emailAdmin, body, "Key Admin");
            }));
        }