Ejemplo n.º 1
0
 public ActionResult Edit(int id, Subscriber model)
 {
     try
     {
         var subscriber = _context.Subscribers.First(s => s.Id == id);
         subscriber.Email = model.Email;
         subscriber.IsActive = model.IsActive;
         _context.SaveChanges();
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Ejemplo n.º 2
0
        public ActionResult Create(Subscriber model)
        {
            try
            {
                var subscriber = new Subscriber
                {
                    Email = model.Email,
                    IsActive = model.IsActive,
                    Guid = Guid.NewGuid().ToString("N")
                };

                _context.Subscribers.Add(subscriber);
                _context.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 3
0
 public int Subscribe(string email)
 {
     try
     {
         var cache = _context.Subscribers.FirstOrDefault(s => s.Email == email);
         if (cache == null)
         {
             var subscriber = new Subscriber
             {
                 Email = email,
                 IsActive = true,
                 Guid = Guid.NewGuid().ToString("N")
             };
             _context.Subscribers.Add(subscriber);
             _context.SaveChanges();
         }
     }
     catch
     {
         
         
     }
     return 0;
 }