public IEnumerable <PictUser> GetSearchPictUser() { masWords = Words.Split(' '); Func <User, bool> SearchUsFunc = SearchUs; IEnumerable <User> us = Users.Where(SearchUsFunc); IEnumerable <Picture> pict = Pictures.Where(p => { foreach (string word in masWords) { if (word == p.Title || word == p.Direction) { return(true); } } return(false); }); IEnumerable <PictUser> pu1 = pict.Join(Users, p => p.UserId, c => c.Id, (p, c) => new PictUser { Id = p.Id, Title = p.Title, Direction = p.Direction, Price = p.Price, Data = p.Data, Name = c.Name, Surname = c.Surname, IdUser = c.Id }); IEnumerable <PictUser> pu2 = Pictures.Join(us, p => p.UserId, c => c.Id, (p, c) => new PictUser { Id = p.Id, Title = p.Title, Direction = p.Direction, Price = p.Price, Data = p.Data, Name = c.Name, Surname = c.Surname, IdUser = c.Id }); return(pu1.Union(pu2, new ComparePictUser())); }
public IEnumerable <PictUser> GetPictUser() { try { var pict = GetPicts(IdUser); var user = Users.FirstOrDefault(u => u.Id == IdUser); List <PictUser> pictUser = new List <PictUser>(); foreach (var p in pict) { pictUser.Add(new PictUser { Id = p.Id, Title = p.Title, Direction = p.Direction, Price = p.Price, Data = p.Data, Name = user.Name, Surname = user.Surname, IdUser = user.Id }); } return(pictUser); } catch { return(Pictures.Join(Users, p => p.UserId, c => c.Id, (p, c) => new PictUser { Id = p.Id, Title = p.Title, Direction = p.Direction, Price = p.Price, Data = p.Data, Name = c.Name, Surname = c.Surname, IdUser = c.Id })); } }