Пример #1
0
        public async Task <ActionResult> DeleteAJAX(int id, bool details, string connectionId, string searchString, DateTime?startDate, DateTime?endDate, bool ownRecords)
        {
            // Удаление элемента из базы
            try
            {
                await _proposalImageRepository.RemoveProposalImages(id, _environment);

                await _proposalRepository.RemoveProposal(id);

                // Декрементирование счетчика новостей для всех пользователей
                await _readedNoticeRepository.DecrementUsersReadedNoticesCounter();

                await _hub.Clients.Client(connectionId).SendAsync("Success", Messages.successDeleteMessage);
            }
            catch { await _hub.Clients.Client(connectionId).SendAsync("Error", Messages.deleteErrorMessage); } // try-catch

            if (details)
            {
                return(RedirectToAction("Index", new { ajaxLoad = true }));
            }
            return(PartialView("_Table", await _proposalRepository.GetFilteredProposals(searchString, startDate, endDate, ownRecords, User.Identity.Name)));
        } // DeleteAJAX