Beispiel #1
0
        public ActionResult Subscribe(FormCollection form)
        {

            var alreadySubscribed = false;
            using (var context = new ContentStorage())
            {

                var subscriber = new Customers {Guid = Guid.NewGuid().ToString()};
                TryUpdateModel(subscriber, new[] { "Name", "Email", "SubscribeType" });

                var email = form["Email"];
                byte subscrType = Convert.ToByte(form["SubscribeType"]);

                var existedEmail = context.Customers.FirstOrDefault(c => c.Email == email && c.SubscribeType == subscrType);
                if (existedEmail == null)
                {
                    context.AddToCustomers(subscriber);
                    context.SaveChanges();
                }
                else
                {
                    alreadySubscribed = true;
                }
            }

            if (!string.IsNullOrEmpty(form["redirectUrl"]) && form["redirectUrl"] == "sbscrList")
                return RedirectToAction("Subscribers", "Subscribe");

            return RedirectToAction(alreadySubscribed ? "AlreadySubscribed" : "ThankYou");
        }
Beispiel #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCustomers(Customers customers)
 {
     base.AddObject("Customers", customers);
 }
Beispiel #3
0
 /// <summary>
 /// Create a new Customers object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="subscribeType">Initial value of the SubscribeType property.</param>
 /// <param name="isActive">Initial value of the IsActive property.</param>
 /// <param name="guid">Initial value of the Guid property.</param>
 public static Customers CreateCustomers(global::System.Int64 id, global::System.String name, global::System.String email, global::System.SByte subscribeType, global::System.SByte isActive, global::System.String guid)
 {
     Customers customers = new Customers();
     customers.Id = id;
     customers.Name = name;
     customers.Email = email;
     customers.SubscribeType = subscribeType;
     customers.IsActive = isActive;
     customers.Guid = guid;
     return customers;
 }