protected virtual void Apply(Resource r)
 {
     if (null != Availability)
     {
         Availability.Apply(r);
     }
 }
 public void Apply(Resource r)
 {
     r.Enabled = Enabled;
     r.Archived = Archived;
     r.Availability = new Availability
     {
         Mode = Mode,
         From = From,
         To = To,
         Users = Users,
         Groups = Groups,
     };
 }
 public static AvailabilityEditModel FromResource(Resource r)
 {
     var availability = r.Availability ?? Availability.Public;
     return new AvailabilityEditModel
     {
         Enabled = r.Enabled,
         Archived = r.Archived,
         Mode = availability.Mode,
         From = availability.From,
         To = availability.To,
         Users = availability.Users,
         Groups = availability.Groups,
     };
 }
 protected virtual void Init(Resource r)
 {
     Availability = AvailabilityEditModel.FromResource(r);
 }