Exemple #1
0
        public virtual ActionResult UserHubs(FormCollection userHubs)
        {
            var hubModel = Session["Hubs"] as Cats.Models.Hubs.UserHubsModel;
            var userName = Session["UserName"].ToString();

            if (hubModel != null)
            {
                for (var i = 0; i < hubModel.UserHubs.Count(); i++)
                {
                    var model = new Cats.Models.Hubs.UserHubModel
                    {
                        HubID = hubModel.UserHubs[i].HubID, Name = hubModel.UserHubs[i].Name
                    };
                    model.Selected = userHubs.GetValue(string.Format("[{0}].Selected", model.HubID)).AttemptedValue.Contains("true");
                    if (model.Selected == hubModel.UserHubs[i].Selected)
                    {
                        continue;
                    }
                    var userID = (from v in _userProfileService.GetAllUserProfile()
                                  where v.UserName == userName
                                  select v.UserProfileID).FirstOrDefault();

                    var hub = new Cats.Models.Hubs.Hub();
                    if (model.Selected)
                    {
                        _userHubService.AddUserHub(model.HubID, userID);
                    }
                    else
                    {
                        _userHubService.RemoveUserHub(model.HubID, userID);
                    }
                }
            }

            return(Json(new { success = true }));
        }
Exemple #2
0
        public virtual ActionResult UserHubs(FormCollection userHubs)
        {
            var hubModel = Session["Hubs"] as Cats.Models.Hubs.UserHubsModel;
            var userName = Session["UserName"].ToString();
            if (hubModel!=null)
            {
                for (var i = 0; i < hubModel.UserHubs.Count(); i++)
                {
                    var model = new Cats.Models.Hubs.UserHubModel
                        {HubID = hubModel.UserHubs[i].HubID, Name = hubModel.UserHubs[i].Name};
                    model.Selected = userHubs.GetValue(string.Format("[{0}].Selected", model.HubID)).AttemptedValue.Contains("true");
                    if (model.Selected == hubModel.UserHubs[i].Selected) continue;
                    var userID = (from v in _userProfileService.GetAllUserProfile()
                                  where v.UserName == userName
                                  select v.UserProfileID).FirstOrDefault();

                    var hub = new Cats.Models.Hubs.Hub();
                    if (model.Selected)
                    {
                        _userHubService.AddUserHub(model.HubID,userID);
                    }else
                    {
                        _userHubService.RemoveUserHub(model.HubID, userID);
                    }
                }
            }

            return Json(new { success = true });
        }