public IActionResult Edit(EmailSubscribeEditModel model) { if (!ModelState.IsValid) { return(View(model)); } var dbModel = _emailSubscriptionRepository.Get(model.EmailSubscriptionId); dbModel.Email = model.Email; dbModel.IsSubscribed = model.IsSubscribed; _emailSubscriptionRepository.Update(dbModel); return(RedirectToAction("index")); }
public IActionResult Subscribe(EmailSubscribeModel model) { if (!ModelState.IsValid) { throw new Exception("invalid email submission"); } var emailDbModel = _emailSubscriptionRepository.Get(model.Email); if (emailDbModel == null || emailDbModel.EmailSubscriptionId == 0) { _emailSubscriptionRepository.Create(new Data.Models.Db.EmailSubscription() { Email = model.Email, IsSubscribed = true }); } return(View()); }