public List <Comment> GetComments(int?id) { List <Post> posts = UsersList.Find(y => y?.Id == id)?.Posts; List <Comment> Сomments = new List <Comment>(); posts?.ForEach(x => x?.Comments?.ForEach(y => Сomments?.Add(y))); Сomments = (from com in Сomments where com.Body.Length < 50 select com).ToList(); return(Сomments); }
internal static void AddWinUserToDB(System.Security.Principal.WindowsIdentity idWindows) { var dbUser = UsersList.Find((a) => a.WindowsAccountName == idWindows.Name); var adminUser = UsersList.Find((a) => a.WindowsAccountName == "admin"); if (dbUser != null) { MessageBox.Show("The windows user " + idWindows.Name + " already exists in DB"); } else { var cloneAdminUser = UsersList.Find((a) => a.WindowsAccountName == "LANA-PC\\Lana"); dbUser = cloneAdminUser; ENTValidationErrors validationErrors = null; dbUser.Save(ref validationErrors, 0);//pass ID = 0, as it is new user } }
public List <Todo> GetTodos(int?id) { List <Todo> Todos = UsersList?.Find(y => y?.Id == id)?.Todos?.Where(x => x?.IsComplete == true)?.ToList(); return(Todos); }
public List <Post> GetCommentsCount(int?id) { return(UsersList?.Find(y => y.Id.Equals(id))?.Posts);; }
public User GetUserByFirstName(string firstName) { return(UsersList.Find(user => user.FirstName == firstName)); }