예제 #1
0
        public ActionResult Add(AddBannedEmailViewModel addBannedEmailViewModel)
        {
            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    if (!string.IsNullOrEmpty(addBannedEmailViewModel.Email))
                    {
                        var bannedEmail = new BannedEmail
                        {
                            Email = addBannedEmailViewModel.Email,
                            DateAdded = DateTime.Now
                        };

                        _bannedEmailService.Add(bannedEmail);

                        TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                        {
                            Message = "Email added",
                            MessageType = GenericMessages.success
                        };

                        unitOfWork.Commit();
                    }
                    else
                    {
                        TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                        {
                            Message = "Please add an email address",
                            MessageType = GenericMessages.error
                        };
                    }

                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    LoggingService.Error(ex);
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message = LocalizationService.GetResourceString("Errors.GenericMessage"),
                        MessageType = GenericMessages.error
                    };
                }
            }

            return RedirectToAction("Index");
        }
예제 #2
0
 public void Delete(BannedEmail bannedEmail)
 {
     _bannedEmailRepository.Delete(bannedEmail);
 }
예제 #3
0
 public BannedEmail Add(BannedEmail bannedEmail)
 {
     return _bannedEmailRepository.Add(bannedEmail);
 }
예제 #4
0
 public void Delete(BannedEmail bannedEmail)
 {
     _context.BannedEmail.Remove(bannedEmail);
 }
예제 #5
0
 public BannedEmail Add(BannedEmail bannedEmail)
 {
     return _context.BannedEmail.Add(bannedEmail);
 }