Beispiel #1
0
        public int Edit(Linhvuc lv)
        {
            Linhvuc lvs = tb.Linhvuc.Find(lv.Idlv);

            lvs.Tenlv = lv.Tenlv;
            try
            {
                tb.Entry(lvs).State = EntityState.Modified;
                tb.SaveChanges();
                return(1);
            }
            catch
            {
                throw;
            }
        }
Beispiel #2
0
        public int Create([FromBody] Linhvuc lv)
        {
            lv.Idlv = Auto_id();

            tb.Linhvuc.Add(lv);
            try
            {
                if (ModelState.IsValid)
                {
                    tb.SaveChanges();
                }
                return(1);
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
Beispiel #3
0
        public int Delete(string id)
        {
            try
            {
                Linhvuc lv = tb.Linhvuc.Find(id);

                if (lv != null)
                {
                    tb.Linhvuc.Remove(lv);
                    tb.SaveChanges();
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch
            {
                throw;
            }
        }