Пример #1
0
        public GetUserDto GetById(int id)
        {
            User user = context.Users
                        .FirstOrDefault(u => u.Id == id);

            if (user == null)
            {
                return(null);
            }
            return(GetUserDto.FromUser(user));
        }
Пример #2
0
        public GetUserDto Delete(int id)
        {
            var existing = context.Users.FirstOrDefault(u => u.Id == id);

            if (existing == null)
            {
                return(null);
            }

            context.Users.Remove(existing);
            context.SaveChanges();

            return(GetUserDto.FromUser(existing));
        }