public JsonResult CapNhatLoaiSanPham([FromBody] LoaiSanPham loai)
        {
            var cate = ketnoidatabase.LoaiSanPham.Find(loai.Id);

            if (cate == null)
            {
                throw new Exception("Khong the cap nhat");
            }
            else
            {
                cate.Ten  = loai.Ten;
                cate.MoTa = loai.MoTa;
                ketnoidatabase.Entry(cate).State = EntityState.Modified;
                ketnoidatabase.SaveChanges();
            }
            return(Json(true));
        }
Exemplo n.º 2
0
        public JsonResult TaoKhachHang([FromBody] KhachHang kh)
        {
            var cus = ketnoidatabase.KhachHang.Find(kh.Id);

            if (cus != null)
            {
                throw new Exception("Tồn Tại Khách Hàng Trong Hệ Thống");
            }
            ketnoidatabase.KhachHang.Add(kh);
            ketnoidatabase.SaveChanges();
            return(Json(kh));
        }
Exemplo n.º 3
0
        public async Task <JsonResult> TaoSanPham([FromBody] SanPham sanpham)
        {
            var prodt = ketnoidatabase.SanPham.Find(sanpham.Id);

            if (prodt != null)
            {
                throw new Exception("San Pham Khong Ton Tai");
            }
            await ketnoidatabase.SanPham.AddAsync(sanpham);

            ketnoidatabase.SaveChanges();
            return(Json(true));
        }