Beispiel #1
0
        public void AddUser(components.User _user)
        {
            User user = new User {
                Id = _user.Id, Name = _user.Name, Lastname = _user.Lastname, Birthday = _user.Birthday
            };

            context.Users.Add(user);
            context.SaveChanges();
        }
Beispiel #2
0
        public void EditUser(components.User _user)
        {
            User currentUser = new User {
                Id = _user.Id, Name = _user.Name, Lastname = _user.Lastname, Birthday = _user.Birthday
            };

            var result = from user in context.Users
                         where user.Id == currentUser.Id
                         select user;
            User user1 = (User)result.ToList()[0];

            context.Entry(user1).CurrentValues.SetValues(currentUser);
            context.SaveChanges();
        }