コード例 #1
0
 public void Add(Subscription subscription)
 {
     db.Subscriptions.Add(subscription);
 }
コード例 #2
0
        public ActionResult Subscribe(SubscribeFormViewModel details)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // Ensure one signature per email address
                    if (subscriptionService.Validate(details.Email))
                    {
                        return View();
                    }

                    // Create signature
                    var subscription = new Subscription()
                    {
                        Email = details.Email
                    };

                    // Add
                    subscriptionService.Add(subscription);

                    // Send confirmation email
                    emailService.Send(subscription.Email, "Thank-you for subscribing!", "Thank-you for subscribing to receive more infomation on the progress of our bid! If you would like to unsubscribe please let us know via email.");

                    return PartialView("_Success");
                }
                catch (Exception ex)
                {
                    throw;
                }
            }

            var modelStateErrors = ModelState.Values.SelectMany(v => v.Errors);

            return View();
        }