Esempio n. 1
0
        public ActionResult BatchDeletePrivateMessages(BatchDeletePrivateMessagesViewModel viewModel)
        {
            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    var pms = _privateMessageService.GetPrivateMessagesOlderThan(viewModel.Days);
                    var pmToDelete = new List<PrivateMessage>();
                    pmToDelete.AddRange(pms);
                    var count = pmToDelete.Count;
                    foreach (var pm in pmToDelete)
                    {
                        _privateMessageService.DeleteMessage(pm);
                    }
                    unitOfWork.Commit();

                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message = string.Format("{0} Private Messages deleted", count),
                        MessageType = GenericMessages.success
                    };
                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    LoggingService.Error(ex);
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message = ex.Message,
                        MessageType = GenericMessages.danger
                    };
                }
            }

            return View(viewModel);
        } 
Esempio n. 2
0
 public ActionResult BatchDeletePrivateMessages()
 {
     var viewModel = new BatchDeletePrivateMessagesViewModel();
     return View(viewModel);
 }