Example #1
0
 public Location(Pslocation dao)
 {
     Dao = dao ?? throw new ArgumentNullException(paramName: nameof(dao));
     if (dao.Inventory < 0)
     {
         throw new ArgumentException(message: "inventory cannot be negative.",
                                     paramName: nameof(dao));
     }
     PieCount = dao.Inventory;
     ID       = dao.LocationId;
 }
Example #2
0
 public Location(int pieCount)
 {
     if (pieCount < 0)
     {
         throw new ArgumentOutOfRangeException(paramName: nameof(pieCount),
                                               message: "inventory cannot be negative.");
     }
     PieCount = pieCount;
     Dao      = new Pslocation()
     {
         Inventory = pieCount
     };
     PSDBContextProvider.Current.UpdateAndSave(Dao);
     if (Dao.LocationId == default)
     {
         throw new InvalidOperationException("could not register location.");
     }
     ID = Dao.LocationId;
 }