public bool SupplierKey(string supplierId, [FromQuery] KeyTarget target) // p768 & 770 { long keyVal; return(long.TryParse(supplierId ?? target.CategoryId, out keyVal) && dataContext.Suppliers.Find(keyVal) != null); }
//public bool SupplierKey(string supplierId) public bool SupplierKey(string supplierId, [FromQuery] KeyTarget target) //This signature allows both the view and the razor page to use the method { long keyVal; //return long.TryParse(supplierId, out keyVal) && dataContext.Suppliers.Find(keyVal) != null; return(long.TryParse(supplierId ?? target.SupplierId, out keyVal) && dataContext.Suppliers.Find(keyVal) != null); }
public bool CategoryKey(string categoryId, [FromQuery] KeyTarget target) // p768 & 770 { long keyVal; return(long.TryParse(categoryId ?? target.CategoryId, out keyVal) && dataContext.Categories.Find(keyVal) != null); }
//public bool CategoryKey(string categoryId) public bool CategoryKey(string categoryId, [FromQuery] KeyTarget target) //This signature allows both the view and the razor page to use the method { long keyVal; //return long.TryParse(categoryId, out keyVal) && dataContext.Categories.Find(keyVal) != null; return(long.TryParse(categoryId ?? target.CategoryId, out keyVal) && dataContext.Categories.Find(keyVal) != null); }