Пример #1
0
        public int Post(Models.Product value)
        {
            try
            {
                Data.MstProduct NewProduct = new Data.MstProduct();

                NewProduct.Product = value.ProductDescription;

                db.MstProducts.InsertOnSubmit(NewProduct);
                db.SubmitChanges();

                return(NewProduct.Id);
            }
            catch
            {
                return(0);
            }
        }
Пример #2
0
        public HttpResponseMessage Delete(int Id)
        {
            Data.MstProduct DeleteProduct = db.MstProducts.Where(d => d.Id == Id).First();

            if (DeleteProduct != null)
            {
                db.MstProducts.DeleteOnSubmit(DeleteProduct);
                try
                {
                    db.SubmitChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                catch
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest));
                }
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
        }