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)); }
/// <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); } }
public ActionResult DeleteConfirmed(int id) { LoaiDocGia loaiDocGia = db.LoaiDocGias.Find(id); db.LoaiDocGias.Remove(loaiDocGia); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <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); }
public void Create(LoaiDocGiaModel model) { var entity = new LoaiDocGia() { TenLoaiDocGia = model.TenLoaiDocGia }; _repository.Insert(entity); }
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)); }
public ActionResult Create([Bind(Include = "MaLoaiDG,TenLoaiDG")] LoaiDocGia loaiDocGia) { if (ModelState.IsValid) { db.LoaiDocGias.Add(loaiDocGia); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaiDocGia)); }
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)); }
// 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)); }