public ModelResource(User user)
 {
     if (user == null)
         throw new ArgumentNullException("user");
     if (user.FullName==null)
         throw new ArgumentNullException("user");
     Id = user.ID;
     Name = user.FullName;
 }
        private User CreateOrUpdateUser(string username, string fullname, string telephone, DataContext db)
        {

            User existingUser = db.Users.FirstOrDefault(u => u.Username == username || u.FullName == fullname);
            if (existingUser != null)
            {
                existingUser.FullName = fullname;
                existingUser.Telephone = telephone;
                db.SaveChanges();
                return existingUser;
            }
            else
            {
                User newUser = new User()
                {
                    Username = username,
                    FullName = fullname,
                    Telephone = telephone,
                    Email = string.Format("{0}@change.me.com", username),
                    AccessKey = UsersRepository.Instance.GenerateAccessKey()
                };
                db.Users.Add(newUser);
                db.SaveChanges();
                return newUser;
            }

        }