public ActionResult NewEntry([Bind(Include = "CustomerName,CustomerEmail,ProductId")] TrialTrackerRecord vm) { if (ModelState.IsValid) { var product = _productService.GetProductById(vm.ProductId); vm.ProductName = product.Name; vm.DownloadDate = DateTime.Now.ToString("MM/dd/yyyy"); // check if they should be auto added to mailing list if (_settings.GetSettingByKey <bool>("AutoAddTrialEmail")) { vm.OnMailingList = true; NewsLetterSubscription subscriber = new NewsLetterSubscription { Active = true, CreatedOnUtc = DateTime.Now, Email = vm.CustomerEmail }; _mailingService.InsertNewsLetterSubscription(subscriber); } else { vm.OnMailingList = false; } _trialRepo.Insert(vm); return(View("_DownloadLink", vm)); } else { return(View()); } }
public void HandleEvent(EntityDeleted <NewsLetterSubscription> eventMessage) { TrialTrackerRecord entity = _trialRepo.Table.Where(x => x.CustomerEmail == eventMessage.Entity.Email).FirstOrDefault(); entity.OnMailingList = false; _trialRepo.Update(entity); }