Esempio n. 1
0
 private string ValidateNewOrder(clsOrders prOrder)
 {
     if (prOrder.Name == "" || prOrder.Email == "")
     {
         return("Name or Email Required");
     }
     else if (IsPhoneBooked(prOrder.ProductId))
     {
         return("This product is out of stock");
     }
     else
     {
         return("true");
     }
 }
Esempio n. 2
0
 public string DeleteOrder(clsOrders prOrder)
 {
     try
     {
         int lcRecCount = ClsDBConnection.Execute(
             "DELETE FROM tbl_orders WHERE id = @Id",
             prepareOrderParameters(prOrder));
         if (lcRecCount == 1)
         {
             return("Order is deleted");
         }
         else
         {
             return("Error Unexpected order confirm count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
Esempio n. 3
0
 public string PutConfirmOrder(clsOrders prOrder)
 {
     try
     {
         int lcRecCount = ClsDBConnection.Execute(
             "UPDATE tbl_orders SET status = 1 WHERE id = @Id and updated_at = @UpdatedAt",
             prepareOrderParameters(prOrder));
         if (lcRecCount == 1)
         {
             return("Order is confirmed");
         }
         else
         {
             return("Error Unexpected order confirm count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
Esempio n. 4
0
        public string PostOrder(clsOrders prOrder)
        {
            var validString = ValidateNewOrder(prOrder);

            if (validString == "true")
            {
                try
                {
                    int lcRecCount = ClsDBConnection.Execute("INSERT INTO `tbl_orders` (`name`, `status`, `email`, " +
                                                             "`amount`, `product_id`) VALUES (@Name, 0, @Email, @Amount, @ProductId)", prepareOrderParameters(prOrder));
                    if (lcRecCount == 1)
                    {
                        int lcRecUpdateCount = ClsDBConnection.Execute(
                            "UPDATE tbl_all_products SET availability = 'Not Available' WHERE id = " + prOrder.ProductId + "",
                            null);
                        if (lcRecUpdateCount == 1)
                        {
                            return("Your order is completed.");
                        }
                        else
                        {
                            return("Error Unexpected order confirm count: " + lcRecCount);
                        }
                    }
                    else
                    {
                        return("Error Unexpected Product insert count: " + lcRecCount);
                    }
                }
                catch (Exception ex)
                {
                    return("Error: " + ex.GetBaseException().Message);
                }
            }
            else
            {
                return(validString);
            }
        }