Esempio n. 1
0
 public void Delete(Ncc obj)
 {
     using (var db = new QLBH_WinDBContext())
     {
         db.Nccs.Attach(obj);
         db.Nccs.Remove(obj);
         db.SaveChanges();
     }
 }
Esempio n. 2
0
 public Ncc Insert(Ncc obj)
 {
     using (var db = new QLBH_WinDBContext())
     {
         db.Nccs.Add(obj);
         db.SaveChanges();
         return(obj);
     }
 }
Esempio n. 3
0
 public void Update(Ncc obj)
 {
     using (var db = new QLBH_WinDBContext())
     {
         db.Nccs.Attach(obj);
         db.Entry(obj).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 4
0
 public async Task <ActionResult <NccDTO> > Add(Ncc ncc)
 {
     try
     {
         return(await repo.AddNcc(ncc));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 5
0
        public bool Edit(int mancc, string tenncc)
        {
            var edit = new Ncc();

            using (var db = new QLBH_WinDBContext())
            {
                edit        = db.Nccs.Where(p => p.MaNcc.Equals(mancc)).SingleOrDefault();
                edit.TenNcc = tenncc;

                db.Nccs.Attach(edit);
                db.Entry(edit).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(false);
        }
Esempio n. 6
0
        public async Task <ActionResult> Update(Ncc ncc)
        {
            try
            {
                if (await repo.Update(ncc))
                {
                    return
                        (Ok("Sửa Thành Công"));
                }

                return
                    (BadRequest("Sửa Thất Bại"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 7
0
        public bool Them(string tenncc)
        {
            var them = new Ncc();

            using (var db = new QLBH_WinDBContext())
            {
                try
                {
                    them.TenNcc = tenncc;
                    db.Nccs.Add(them);
                    db.SaveChanges();
                }
                catch
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 8
0
        public bool Delete(int mancc)
        {
            var del  = new Ncc();
            var data = new DataGridView();

            using (var db = new QLBH_WinDBContext())
            {
                try
                {
                    del = db.Nccs.Where(p => p.MaNcc.Equals(mancc)).SingleOrDefault();
                    db.Nccs.Attach(del);
                    db.Nccs.Remove(del);
                    db.SaveChanges();
                }
                catch
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 9
0
 public static void Update(Ncc obj)
 {
     Ncc.Update(obj);
 }
Esempio n. 10
0
 public static Ncc Insert(Ncc obj)
 {
     return(Ncc.Insert(obj));
 }
Esempio n. 11
0
 public static void Delete(Ncc obj)
 {
     Ncc.Delete(obj);
 }
Esempio n. 12
0
 public void Update(Ncc entity)
 {
     _repository.UpdateAsync(entity);
 }
Esempio n. 13
0
 public Task <Ncc> Create(Ncc entity)
 {
     return(_repository.InsertAsync(entity));
 }
Esempio n. 14
0
 public void Update(Ncc entity)
 {
     entity.CreateUserId = _getIdService.CreateIdUser();
     _repository.UpdateAsync(entity);
 }
Esempio n. 15
0
 public Task <Ncc> CreateOrUpdate(Ncc entity)
 {
     entity.CreateUserId = _getIdService.CreateIdUser();
     return(_repository.InsertOrUpdateAsync(entity));
 }