Example #1
0
        public ActionResult BrAlternatives([FromJson] BrAlternativesVM brAlternativesVM)
        {
            IssueBrAlternative iba = new IssueBrAlternative();
            int userId             = GetUserIdFromClaim();

            iba.UpdateAlternatives(brAlternativesVM.Alternatives, brAlternativesVM.DeletedAlternatives, userId);
            brAlternativesVM.Alternatives = iba.GetIssueAlternatives(brAlternativesVM.Issue.Id, userId);

            UserShortModel user    = new UserShortModel(brAlternativesVM.UserId, GetUserNameFromClaim());
            var            context = GlobalHost.ConnectionManager.GetHubContext <AlternativeHub>();

            context.Clients.All.updateAlternatives(brAlternativesVM.Alternatives, user, brAlternativesVM.Issue.Id);
            if (brAlternativesVM.DeletedAlternatives != null && brAlternativesVM.DeletedAlternatives.Count > 0)
            {
                context.Clients.All.deleteAlternatives(brAlternativesVM.DeletedAlternatives, user);
            }

            brAlternativesVM.DeletedAlternatives = new List <int>();
            var ctx2 = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            ctx2.Clients.All.updateActivity(brAlternativesVM.Issue.Id, brAlternativesVM.UserId);
            return(View(brAlternativesVM));
        }