public IHttpActionResult PutGIABAN(string id, GIABAN gIABAN)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != gIABAN.MAGIABAN)
            {
                return(BadRequest());
            }

            db.Entry(gIABAN).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostGIABAN(GIABAN gIABAN)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.GIABANs.Add(gIABAN);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (GIABANExists(gIABAN.MAGIABAN))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = gIABAN.MAGIABAN }, gIABAN));
        }
        public IHttpActionResult GetGIABAN(string id)
        {
            GIABAN gIABAN = db.GIABANs.Find(id);

            if (gIABAN == null)
            {
                return(NotFound());
            }

            return(Ok(gIABAN));
        }
        public IHttpActionResult DeleteGIABAN(string id)
        {
            GIABAN gIABAN = db.GIABANs.Find(id);

            if (gIABAN == null)
            {
                return(NotFound());
            }

            db.GIABANs.Remove(gIABAN);
            db.SaveChanges();

            return(Ok(gIABAN));
        }
        public bool DeleteGiaBan(string id)
        {
            bool   isDelete = false;
            GIABAN giaBan   = db.GIABANs.Find(id);

            if (giaBan != null)
            {
                db.GIABANs.Remove(giaBan);
                db.SaveChanges();
                isDelete = true;
            }
            else
            {
                isDelete = false;
            }
            return(isDelete);
        }
        public GIABAN PostGiaBan(GIABAN giaBan)
        {
            db.GIABANs.Add(giaBan);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (GiaBanExists(giaBan.MAGIABAN))
                {
                }
                else
                {
                    throw;
                }
            }

            return(giaBan);
        }
Exemplo n.º 7
0
 public int UpdateGiaBan(string idProduct, decimal giaban, string idNV)
 {
     try
     {
         var idGia = CreateIDGiaBanAuto("GIA");
         var gia   = new GIABAN()
         {
             MAGIA          = idGia,
             MASANPHAM      = idProduct,
             DONGIABAN      = giaban,
             NGAYCAPNHATGIA = DateTime.Now,
             VAT            = 0,
             NGUOICAPNHAT   = idNV,
         };
         db.GIABANs.Add(gia);
         db.SaveChanges();
         return(1);
     }
     catch
     {
         return(0);
     }
 }