public static Boolean IsAvailable(String username, int Day, int Month, int Year) { Person person = Person.FetchByUsername(username); if (person == null) { return(false); //this shouldn't happen } Availability availability = Availability.FetchByPersonAndDate(person.Id, Month, Year, Day); if (availability == null) { return(false); } return(availability.Isavailable); }
public static void MarkUnavailable(String username, int Day, int Month, int Year) { Person person = Person.FetchByUsername(username); if (person == null) { return; //this shouldn't happen } Availability availability = Availability.FetchByPersonAndDate(person.Id, Month, Year, Day); if (availability == null) { Availability.Insert(person.Id, Month, Year, Day, false); } else { availability.Isavailable = false; availability.Save(); } }