Esempio n. 1
0
        // Xóa theo key
        public int?Delete(int MaDM)
        {
            tbl_danhmuc dbEntry = context.tbl_danhmuc.Find(MaDM);

            if (dbEntry == null)
            {
                return(null);
            }

            context.tbl_danhmuc.Remove(dbEntry);
            context.SaveChanges();
            return(MaDM);
        }
Esempio n. 2
0
        // Thêm 1 đối tượng
        public int?Insert(tbl_danhmuc model)
        {
            tbl_danhmuc dbEntry = context.tbl_danhmuc.Find(model.id);

            if (dbEntry != null)
            {
                return(null);
            }
            context.tbl_danhmuc.Add(model);
            context.SaveChanges();

            return(model.id);
        }
Esempio n. 3
0
        // Sửa dữ liệu
        public int?Update(tbl_danhmuc model)
        {
            tbl_danhmuc dbEntry = context.tbl_danhmuc.Find(model.id);

            if (dbEntry == null)
            {
                return(null);
            }

            dbEntry.ten = model.ten;
            context.SaveChanges();
            return(model.id);
        }
Esempio n. 4
0
        // Trả về 1 đối tượng khi biết khóa
        public tbl_danhmuc FindEntity(int MaDM)
        {
            tbl_danhmuc dbEntry = context.tbl_danhmuc.Find(MaDM);

            return(dbEntry);
        }