示例#1
0
 public void CreateAnOwner()
 {
     SelectOwner dlg = new SelectOwner(this, true);
     if (OwnerNames.Any(s => s.Equals(dlg.OwnerName, StringComparison.OrdinalIgnoreCase)))
         return;
     if (DialogResult.OK == dlg.ShowDialog())
     {
         _model.SaveObject<Owner>(
             new Owner
             {
                 Name = dlg.OwnerName
             });
     }
 }
示例#2
0
 public void AdoptACat(Cat cat)
 {
     if (Equals(null, _model)) return;
     if (!IsAdoptable(cat)) return;
     SelectOwner dlg = new SelectOwner(this, false);
     if (DialogResult.OK == dlg.ShowDialog() && 0 < _ownerNameInProgress.Length)
     {
         IEnumerable<Owner> allOwners = _model.GetAll<Owner>();
         var owners =
             from owner in allOwners
             where 0 == String.Compare(owner.Name, _ownerNameInProgress, true)
             select owner;
         if (owners.Count<Owner>() > 0)
         {
             cat.MyOwner = owners.ElementAt<Owner>(0);
             _model.SaveObject<Cat>(cat);
         }
     }
 }