public ActionResult AddAuthor(string tacgia) { try { var item = tacGiaService.GetByShortName(Help.Helper.convertToUnSign3(tacgia)); if (item != null) { return(Json(new { Success = false, Flag = 1, Message = "Tác giả này đã tồn tại!" })); } else { tacGiaService.Add(new OTacGia { Ten = tacgia, TenVanTat = Help.Helper.convertToUnSign3(tacgia), TrangThai = true, }); return(Json(new { Success = true })); } } catch (Exception e) { } return(Json(new { Success = false, Flag = 0, Error = "Thêm thất bại" })); }
public ActionResult Add(TacGiaViewModel model) { if (ModelState.IsValid) { model.CreateDate = DateTime.Now; TacGia tacGia = new TacGia(); tacGia.UpdateTacGia(model); _tacGiaService.Add(tacGia); _context.SaveChanges(); ViewData["successMsg"] = "Thêm thành công"; } return(View()); }
public ActionResult Create(OTacGia model) { if (ModelState.IsValid) { try { tgService.Add(model); return(RedirectToAction("Search", "QuanLyTacGia")); } catch (Exception e) { } } ViewBag.IsEdit = true; return(View("Update", model)); }