public IHttpActionResult PostSale(Sale sale)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Sales.Add(sale);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = sale.SaleId }, sale);
        }
 public void Edit(Sale b)
 {
     context.Entry(b).State = System.Data.Entity.EntityState.Modified;
 }
 public void Add(Sale b)
 {
     context.Sales.Add(b);
     context.SaveChanges();
 }
        public IHttpActionResult PutSale(int id, Sale sale)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != sale.SaleId)
            {
                return BadRequest();
            }

            //db.Entry(sale).State = EntityState.Modified;
            db.MarkAsModified(sale);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SaleExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
 public void MarkAsModified(Sale item)
 {
     Entry(item).State = EntityState.Modified;
 }
 public void MarkAsModified(Sale item)
 {
 }