public IHttpActionResult CreateNewCustomer(CustomerRegistraionInfo customerInfo)
        {
            Customer customer = new Customer()
            {
                FIRST_NAME         = customerInfo.FIRST_NAME,
                LAST_NAME          = customerInfo.LAST_NAME,
                USER_NAME          = customerInfo.USER_NAME,
                PASSWORD           = customerInfo.PASSWORD,
                ADDRESS            = customerInfo.ADDRESS,
                PHONE_NO           = customerInfo.PHONE_NO,
                CREDIT_CARD_NUMBER = customerInfo.CREDIT_CARD_NUMBER
            };

            try
            {
                CustomerMvcController cus = new CustomerMvcController();
                anonymousUser.CreateNewCustomer(customer);
                cus.Email(customerInfo);
                return(Ok("Account created successfully! Please verify your email"));
            }
            catch (Exception e)
            {
                if (customer == null)
                {
                    return(BadRequest("Bad info was given! "));
                }
                return(BadRequest(e.Message));
            }
        }
Пример #2
0
        public static async Task Execute(CustomerRegistraionInfo customerInfo)
        {
            var apiKey           = "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";
            var client           = new SendGridClient(apiKey);
            var from             = new EmailAddress("*****@*****.**");
            var subject          = "Confirmation Email";
            var to               = new EmailAddress(customerInfo.Email);
            var plainTextContent = "and easy to do anywhere, even with C#";

            myGuid = Guid.NewGuid().ToString();
            var htmlContent = "Click here to verify your account:<br>http://localhost:58981/CustomerMvc/ConfirmEmail?guid=" + myGuid;
            var msg         = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
            var response    = await client.SendEmailAsync(msg);
        }
Пример #3
0
        // GET: CustomerMvc
        public ActionResult Email(CustomerRegistraionInfo customerInfo)
        {
            Execute(customerInfo).Wait(3000);

            return(Content("Email sent"));
        }