public bool CreateSales()
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json  = new StreamReader(req).ReadToEnd();
            var    sales = JsonConvert.DeserializeObject <Dictionary <string, string> >(json);

            if (!checkKeyValue(sales, "CustomerId") ||
                !checkKeyValue(sales, "StoreId") ||
                !checkKeyValue(sales, "ProductId"))
            {
                return(false);
            }

            if (!checkCustomer(getInteger(sales["CustomerId"])) ||
                !checkProduct(getInteger(sales["ProductId"])) ||
                !checkStore(getInteger(sales["StoreId"])))
            {
                return(false);
            }

            Sales newSale = new Sales();

            newSale.CustomerId = Convert.ToInt32(sales["CustomerId"]);
            newSale.StoreId    = Convert.ToInt32(sales["StoreId"]);
            newSale.ProductId  = Convert.ToInt32(sales["ProductId"]);

            if (sales.ContainsKey("DateSold"))
            {
                DateTime date;
                try
                {
                    CultureInfo culture = new CultureInfo("en-US");
                    date = Convert.ToDateTime(sales["DateSold"], culture);
                }
                catch (Exception) { return(false); }

                newSale.DateSold = date;
            }
            else
            {
                newSale.DateSold = DateTime.Now;
            }
            return(salesDAL.AddSales(newSale));
        }
 public Sales Post(Sales sales)
 {
     return(ObjectSales.AddSales(sales));
 }