Exemplo n.º 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.UtcNow
                        };

                        _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.danger
                        };
                    }
                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    LoggingService.Error(ex);
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = LocalizationService.GetResourceString("Errors.GenericMessage"),
                        MessageType = GenericMessages.danger
                    };
                }
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
    protected void banUser(object sender, EventArgs e)
    {
        var dc    = new DulyDBDataContext();
        var qUser = (from u in dc.Users
                     where u.displayName == txtUsername.Text
                     select u).First();

        var banUser = new BannedEmail
        {
            email = qUser.email
        };

        dc.BannedEmails.InsertOnSubmit(banUser);
        dc.SubmitChanges();
        banStatus(qUser.email);
        binddata(qUser.userId);
    }
        public ActionResult Add(AddBannedEmailViewModel addBannedEmailViewModel)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(addBannedEmailViewModel.Email))
                {
                    var bannedEmail = new BannedEmail
                    {
                        Email     = addBannedEmailViewModel.Email,
                        DateAdded = DateTime.Now
                    };

                    _bannedEmailService.Add(bannedEmail);

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

                    Context.SaveChanges();
                }
                else
                {
                    TempData[Constants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = "Please add an email address",
                        MessageType = GenericMessages.danger
                    };
                }
            }
            catch (Exception ex)
            {
                Context.RollBack();
                LoggingService.Error(ex);
                TempData[Constants.MessageViewBagName] = new GenericMessageViewModel
                {
                    Message     = LocalizationService.GetResourceString("Errors.GenericMessage"),
                    MessageType = GenericMessages.danger
                };
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
 public void Delete(BannedEmail bannedEmail)
 {
     _context.BannedEmail.Remove(bannedEmail);
 }
Exemplo n.º 5
0
 public BannedEmail Add(BannedEmail bannedEmail)
 {
     return(_context.BannedEmail.Add(bannedEmail));
 }
Exemplo n.º 6
0
 public void Delete(BannedEmail bannedEmail)
 {
     _context.BannedEmail.Remove(bannedEmail);
 }
Exemplo n.º 7
0
 public BannedEmail Add(BannedEmail bannedEmail)
 {
     return _context.BannedEmail.Add(bannedEmail);
 }
Exemplo n.º 8
0
 public void Delete(BannedEmail bannedEmail)
 {
     _bannedEmailRepository.Delete(bannedEmail);
 }
Exemplo n.º 9
0
 public BannedEmail Add(BannedEmail bannedEmail)
 {
     return(_bannedEmailRepository.Add(bannedEmail));
 }