Esempio n. 1
0
 public Response saveChanges() {
   boolean ok = RepositoryFactory.getProfileRepo().Update(this);
   if (ok) {
     return new Response(true, "");
   } else {
     return new Response(false, "Error occured while saving profile.");
   }
 }
Esempio n. 2
0
 public static Response createProfile(
     String userName, int age, double height, int gender, String password) {
   if (userName.equals(Administrator.ADMIN_USERNAME))
     return new Response(false, "Can not create profile with this username.");
   if (userName == null || userName.equals(""))
     return new Response(false, "Can not create profile with empty username.");
   if (password == null || password.length() < 3)
     return new Response(false, "Can not create profile with password less than 3 characters.");
   UserProfile p = new UserProfile();
   p.userName = userName;
   p.age = age;
   p.height = height;
   p.gender = gender;
   p.password = password;
   p.goal = null;
   p.statistics = new ProfileStatistics(p);
   if (RepositoryFactory.getProfileRepo().GetByUserName(userName) != null)
     return new Response(false, "User already exists.");
   boolean ok = RepositoryFactory.getProfileRepo().Add(p);
   if (ok) return new Response(true, "");
   else return new Response(false, "Error occured while creating new profile.");
 }