示例#1
0
 /// <summary>
 /// Adds a manager to the database
 /// </summary>
 /// <param name="manager">manager to be added</param>
 /// <returns>added manager</returns>
 public DogManager AddManager(DogManager manager)
 {
     Entity.DogManager dogManager = new Entity.DogManager();
     dogManager.UserName    = manager.Name;
     dogManager.PhoneNumber = manager.PhoneNumber;
     dogManager.UserAddress = manager.Address;
     _context.DogManagers.Add(dogManager);
     _context.SaveChanges();
     return(manager);
 }
示例#2
0
 /// <summary>
 /// Finds manager in the database based on phone number
 /// </summary>
 /// <param name="phoneNumber">phone number to find the manager by</param>
 /// <returns>manager in the database if found and null otherwise</returns>
 public DogManager FindManager(long phoneNumber)
 {
     try{
         Entity.DogManager dogManager = (
             from DogManager in _context.DogManagers where
             DogManager.PhoneNumber == phoneNumber
             select DogManager
             ).Single();
         return(new Model.DogManager(dogManager.PhoneNumber, dogManager.UserAddress, dogManager.UserName));
     }catch (Exception e) {
         Log.Debug(e.Message);
         return(null);
     }
 }