コード例 #1
0
        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);
        }
コード例 #2
0
        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
            }
        }
コード例 #3
0
        public List <Todo> GetTodos(int?id)
        {
            List <Todo> Todos = UsersList?.Find(y => y?.Id == id)?.Todos?.Where(x => x?.IsComplete == true)?.ToList();

            return(Todos);
        }
コード例 #4
0
 public List <Post> GetCommentsCount(int?id)
 {
     return(UsersList?.Find(y => y.Id.Equals(id))?.Posts);;
 }
コード例 #5
0
 public User GetUserByFirstName(string firstName)
 {
     return(UsersList.Find(user => user.FirstName == firstName));
 }