コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("LoaiDocGiaID,TenDocGia")] LoaiDocGia loaiDocGia)
        {
            if (id != loaiDocGia.LoaiDocGiaID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(loaiDocGia);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LoaiDocGiaExists(loaiDocGia.LoaiDocGiaID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(loaiDocGia));
        }
コード例 #2
0
 /// <summary>
 /// thêm thông tin loại đọc giả vào database
 /// </summary>
 public static void AddLoaiDocGia(LoaiDocGia LoaiDocGia)
 {
     using (var db = new LiteDatabase(DatabaseConnectionString))
     {
         db.GetCollection <LoaiDocGia>("LoaiDocGia").Insert(LoaiDocGia);
     }
 }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            LoaiDocGia loaiDocGia = db.LoaiDocGias.Find(id);

            db.LoaiDocGias.Remove(loaiDocGia);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        /// <summary>
        /// cập nhật thông tin loại đọc giả vào database
        /// </summary>
        public static bool SetDocGia(LoaiDocGia LoaiDocGia)
        {
            bool result;

            using (var db = new LiteDatabase(DatabasePath)) {
                result = db.GetCollection <LoaiDocGia>("LoaiDocGia").Update(LoaiDocGia);
            }
            return(result);
        }
コード例 #5
0
        public void Create(LoaiDocGiaModel model)
        {
            var entity = new LoaiDocGia()
            {
                TenLoaiDocGia = model.TenLoaiDocGia
            };

            _repository.Insert(entity);
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "MaLoaiDG,TenLoaiDG")] LoaiDocGia loaiDocGia)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loaiDocGia).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(loaiDocGia));
 }
コード例 #7
0
        public ActionResult Create([Bind(Include = "MaLoaiDG,TenLoaiDG")] LoaiDocGia loaiDocGia)
        {
            if (ModelState.IsValid)
            {
                db.LoaiDocGias.Add(loaiDocGia);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(loaiDocGia));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("LoaiDocGiaID,TenDocGia")] LoaiDocGia loaiDocGia)
        {
            if (ModelState.IsValid)
            {
                _context.Add(loaiDocGia);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(loaiDocGia));
        }
コード例 #9
0
        // GET: LoaiDocGia_59132942/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LoaiDocGia loaiDocGia = db.LoaiDocGias.Find(id);

            if (loaiDocGia == null)
            {
                return(HttpNotFound());
            }
            return(View(loaiDocGia));
        }