Exemplo n.º 1
0
        private Dictionary <string, object> prepareProductParameters(clsProducts prProducts)
        {
            Dictionary <string, object> par = new Dictionary <string, object>(10);

            par.Add("Category", prProducts.Category);
            par.Add("DVDName", prProducts.DVDName);
            par.Add("Description", prProducts.Description);
            par.Add("DVDCondition", prProducts.DVDCondition);
            par.Add("DVDType", prProducts.DVDType);
            par.Add("Price", prProducts.Price);
            //par.Add("LastModified", prProducts.LastModified);
            par.Add("QuanityInStock", prProducts.QuanityInStock);


            return(par);
        }
Exemplo n.º 2
0
 [HttpPut] public string UpdateQuanityInStock(clsProducts prProduct)
 {
     try
     {
         int lcRecCount = clsDBConnection.Execute(
             "UPDATE Products SET QuanityInStock = @QuanityInStock WHERE DVDName = @DVDName",
             prepareProductParameters(prProduct));
         if (lcRecCount == 1)
         {
             return("Order Updated");
         }
         else
         {
             return("Unexpected order update count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
Exemplo n.º 3
0
 public string PutProduct(clsProducts prProduct)
 {
     try
     {
         int lcRecCount = clsDBConnection.Execute(
             "UPDATE Products SET Description = @Description, Price = @Price, LastModified = Now(), QuanityInStock = @QuanityInStock, DVDCondition = @DVDCondition WHERE DVDName = @DVDName",
             prepareProductParameters(prProduct));
         if (lcRecCount == 1)
         {
             return("One Product Updated");
         }
         else
         {
             return("Unexpected Product Update Count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
Exemplo n.º 4
0
 public string DeleteProduct(clsProducts prProduct)
 {
     try
     {
         int lcRecCount = clsDBConnection.Execute(
             "DELETE FROM Products WHERE DVDName = @DVDName AND Category = @Category",
             prepareProductParameters(prProduct));
         if (lcRecCount == 1)
         {
             return("One Product Deleted");
         }
         else
         {
             return("Unexpected Product Delete count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
Exemplo n.º 5
0
 public string PostProduct(clsProducts prProduct)
 {   // insert
     try
     {
         int lcRecCount = clsDBConnection.Execute("INSERT INTO Products " +
                                                  "(DVDName, Description, Price, DVDType, LastModified, QuanityInStock, DVDCondition, Category) " +
                                                  "VALUES (@DVDName, @Description, @Price, @DVDType, Now(), @QuanityInStock, @DVDCondition, @Category)",
                                                  prepareProductParameters(prProduct));
         if (lcRecCount == 1)
         {
             return("One Product Added");
         }
         else
         {
             return("Unexpected Product Insert Count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }