Пример #1
0
        public IHttpActionResult PutHangSX(string id, HangSX hangSX)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != hangSX.IDHSX)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult PutTSDongHo(int id, TSDongHo tSDongHo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tSDongHo.IDDH)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public IHttpActionResult PutUser(string id, User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.UserName)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #4
0
        public IHttpActionResult PutNhapKho(string id, NhapKho nhapKho)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != nhapKho.IDNK)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #5
0
        public IHttpActionResult PutKhachHang(string id, KhachHang khachHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != khachHang.IDKH)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #6
0
        public IHttpActionResult PutSanPham(string id, SanPham sanPham)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sanPham.IDSP)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutPhieuNhap(string id, PhieuNhap phieuNhap)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != phieuNhap.IDPN)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #8
0
        public IHttpActionResult PostHoaDonGetIdentity(HoaDon hoaDon)
        {
            using (var entity = new BanHangDBContext())
            {
                hoaDon.IDHD = GetIdentity();
                entity.hoaDons.Add(hoaDon);

                entity.SaveChanges();
            }

            return(Ok(hoaDon));
        }
Пример #9
0
        public IHttpActionResult PostKhachHangGetIdentity(KhachHang khachHang)
        {
            using (var entity = new BanHangDBContext())
            {
                khachHang.IDKH = GetIdentity();
                entity.khachHangs.Add(khachHang);

                entity.SaveChanges();
            }

            return(Ok(khachHang));
        }
Пример #10
0
        public IHttpActionResult PostNhapHoaDonGetIdentity(NhapHoaDon nhapHoaDon)
        {
            using (var entity = new BanHangDBContext())
            {
                nhapHoaDon.IDNHD = GetIdentity();
                entity.nhapHoaDons.Add(nhapHoaDon);

                entity.SaveChanges();
            }

            return(Ok(nhapHoaDon));
        }
        public IHttpActionResult PostPhieuNhapGetIdentity(PhieuNhap phieuNhap)
        {
            using (var entity = new BanHangDBContext())
            {
                phieuNhap.IDPN = GetIdentity();
                entity.phieuNhaps.Add(phieuNhap);

                entity.SaveChanges();
            }

            return(Ok(phieuNhap));
        }
Пример #12
0
        public IHttpActionResult PostListNhapKho(NhapKho[] nhapKhos)
        {
            if (nhapKhos != null)
            {
                for (int i = 0; i < nhapKhos.Length; i++)
                {
                    using (var entity = new BanHangDBContext())
                    {
                        nhapKhos[i].IDNK = GetIdentity();
                        entity.nhapKhos.Add(nhapKhos[i]);
                        entity.SaveChanges();
                    }
                }
                return(Ok(nhapKhos));
            }


            return(NotFound());
        }