public static object SelectionWithId(int[] id)
        {
            List <ClientUser> userList = new List <ClientUser>();

            using (DatingContext db = new DatingContext())
            {
                for (int i = 0; i < id.Length; i++)
                {
                    int currentId = id[i];
                    userList.Add(new ClientUser(db.SiteUsers.FirstOrDefault(x => x.id == currentId)));
                }
            }
            List <Avatar> avatars = AvatarsController.GetAvatars(id);

            return(new { userList, avatars, id });
        }
        public IHttpActionResult GetOneSiteUser(int id)
        {
            ClientUser siteUser = new ClientUser(db.SiteUsers.Find(id));

            if (siteUser == null)
            {
                return(NotFound());
            }
            //Avatar avatar = db.Avatars.FirstOrDefau lt(x => x.siteUserId == id &&
            //                                             x.confirmState == "Confirmed");
            List <Avatar> avatar = AvatarsController.GetAvatars(new int[1] {
                id
            });

            return(Ok(new { siteUser, avatar }));
        }
        private object SortByFilter(Filter filter, int page)// List<ClientUser>
        {
            if (filter.nameForSearch == null)
            {
                filter.nameForSearch = "";
            }


            int startNum = (page - 1) * 12;
            int from     = 0;
            int to       = 0;

            int    ageFilterid  = filter.ageForSearch;
            string ageForSearch = db.AgeForSearch.FirstOrDefault(x => x.id == ageFilterid).rangeOfAge;

            if (ageForSearch != "All")
            {
                from = Convert.ToInt32(ageForSearch.Split(' ')[0]);
                if (from == 53)
                {
                    to = 200;
                }
                else
                {
                    to = Convert.ToInt32(ageForSearch.Split(' ')[2]);
                }
            }

            //Filter allFiter=new Filter();
            //allFiter.ageForSearch = db.AgeForSearch.FirstOrDefault(x => x.rangeOfAge == "All").id;
            //allFiter.cityForSearch = db.Cities.FirstOrDefault(x => x.cityName == "All").id;
            //allFiter.genderForSearch = db.TypeForSearch.FirstOrDefault(x => x.typeName == "All").id;

            if (filter.nameForSearch == null)
            {
                filter.nameForSearch = "";
            }
            using (DatingContext db = new DatingContext())
            {
                List <SiteUser> SUsers = db.SiteUsers.Where(x =>
                                                            ((DateTime.Now.Year - x.birthDay.Year >= from && DateTime.Now.Year - x.birthDay.Year <= to) || filter.ageForSearch == -1) &&
                                                            (x.cityid == filter.cityForSearch || filter.cityForSearch == -1) &&
                                                            (x.typeForSearchid == filter.typeForSearch || filter.typeForSearch == -1) &&
                                                            x.id != filter.id &&
                                                            (x.online == filter.isOnline || x.online == true) &&//online == false тогда фильтр по онлайну отключени и true || false делает выборку всего "игнорируя" этот пункт, если же включен, то выходит true||true тоесть фильтр по онлайну работает
                                                            (x.name.ToLower().Contains(filter.nameForSearch.ToLower()))
                                                            ).OrderBy(x => x.name).Skip(startNum).Take(12).ToList();

                SUsers.Add(db.SiteUsers.FirstOrDefault(x => x.id == filter.id));

                List <ClientUser> userList = new List <ClientUser>();
                foreach (SiteUser user in SUsers)
                {
                    userList.Add(new ClientUser(user));
                }

                List <int> id = new List <int>();//На фронтеэнде его отправим в вебсокет обновления статуса
                for (int i = 0; i < userList.Count; i++)
                {
                    id.Add(userList[i].id);
                }
                List <Avatar> avatars = AvatarsController.GetAvatars(id.ToArray());
                //object sendData = new { userList, avatars };
                return(new { userList, avatars, id });
            }
        }