Exemplo n.º 1
0
        public PartialViewResult _SpreadIP(int IPId)
        {
            var lst = _countryRepository.LoadAndSelect(x => true, x => new SelectListItem_Custom {
                Id = x.Id, Description = x.Name
            }, false).ToSelectList(x => x.Description);

            FillViewData();

            var model = new SpreadViewModel()
            {
                _id     = IPId,
                _filter = new VoicerFilterModel()
                {
                    _frm_id = "voicerfilter_filter"
                },
                _connected = _connectionRepository.GetAllVoicerModelsByFilter(x => x.User1.Active && x.User1.ActiveIPFeeds && x.UserId == _userID && x.Type == VoicerConnectionType.CONNECTED.ToString(),
                                                                              Sorter <UsersConnection> .Get(x => x.DateConnected, false)),
            };

            model._selected = new List <bool>();
            foreach (var item in model._connected)
            {
                model._selected.Add(true);
            }

            model._filter._frm_type = 4;

            return(PartialView("_SpreadForm", model));
        }
Exemplo n.º 2
0
        // GET: Spread
        public ActionResult Index()
        {
            //ViewBag.Title("Enter Spreads");
            SpreadViewModel model = new SpreadViewModel();

            model.SpreadList = db.getAllSpreadRecords();
            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult SpreadIP(SpreadViewModel model)
        {
            try
            {
                var connected = _connectionRepository.GetAllVoicerModelsByFilter(x => x.User1.Active && x.User1.ActiveIPFeeds && x.UserId == _userID && x.Type == VoicerConnectionType.CONNECTED.ToString(),
                                                                                 Sorter <UsersConnection> .Get(x => x.DateConnected, false));
                var userIds = new List <int>();

                if (model._filter != null && !model._filter.isEmpty())
                {
                    var filter = model._filter.GetFilter(_connectionRepository.GetAllBlockedUsers(_userID));
                    filter = filter.And(x => x.ActiveIPFeeds);
                    var voicers = _userRepository.LoadAndSelect(filter, x => x.Id, false);
                    foreach (var item in voicers)
                    {
                        if (!userIds.Contains(item))
                        {
                            userIds.Add(item);
                        }
                    }
                }

                var index = 0;
                foreach (var item in connected)
                {
                    if (model._selected[index] && !userIds.Contains(item.Id))
                    {
                        userIds.Add(item.Id);
                    }
                    index++;
                }

                SpreadToUsers(model._id, userIds);

                // set activity
                _userActivityRepository.SetActivity("ACTIVITY", "Spread", _userID, model._id);

                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json("Failed", JsonRequestBehavior.AllowGet));
            }
        }