public ViewResult Index(PriceLookup price)
{
var connectionString = @"Data Source=" + Server.MapPath("App_Data/prices.s3db");
var priceDb = new PriceDb(connectionString);
if (ModelState.IsValid)
{
if (!string.IsNullOrEmpty(price.Upc))
{
priceDb.GetPriceByUpc(price);
if (price.Price == null)
{
ModelState.AddModelError("NotFound", "UPC not found");
}
}
else if (!string.IsNullOrEmpty(price.Isbn))
{
priceDb.GetPriceByIsbn(price);
if (price.Price == null)
{
ModelState.AddModelError("NotFound", "ISBN not found");
}
}
else
{
ModelState.AddModelError("Required", "You must enter a UPC or an ISBN");
}
}
return(View(price));
}