public void Update(TheLoaiDTO theLoaiDTO) { theloai theloai = _mapper.Map <theloai>(theLoaiDTO); _unitOfWork.TheLoaiRepository.Update(theloai); _unitOfWork.CommitAsync(); }
public ActionResult Create(theloai category) { try { if (ModelState.IsValid) { bool isExists = (from c in db.theloais where c.TenTL == category.TenTL select c.TenTL ).Count() > 0; if (isExists) { ModelState.AddModelError("", "Tên thể loại đã tồn tại! Vui lòng nhập tên khác."); } else { category.TenTL_KhongDau = StringHelper.ToUnsignString(category.TenTL); db.theloais.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } } } catch { ModelState.AddModelError("", "Có lỗi khi thêm mới thông tin Thể loại! Vui lòng thử lại."); } return(View(category)); }
public async Task <TheLoaiDTO> Delete(object id) { theloai theloai = _unitOfWork.TheLoaiRepository.Delete(id); await _unitOfWork.CommitAsync(); return(_mapper.Map <TheLoaiDTO>(theloai)); }
public async Task <TheLoaiDTO> Add(TheLoaiDTO theLoaiDTO) { theloai theloai = _unitOfWork.TheLoaiRepository.Add(_mapper.Map <theloai>(theLoaiDTO)); await _unitOfWork.CommitAsync(); return(_mapper.Map <TheLoaiDTO>(theloai)); }
public theloai CreateCategory([FromBody] theloai model) { model.idtheloai = Guid.NewGuid().ToString(); model.parent_maloai = "10"; _CategoryBusiness.Create(model); return(model); }
public ActionResult Edit(int?id, theloai category) { try { if (ModelState.IsValid) { if (id != null) { if (category.TenTL_KhongDau == null) { ModelState.AddModelError("", "Vui lòng nhập tên Thể loại SEO!"); return(View(category)); } else { var cate = db.theloais.Find(id); cate.TenTL = category.TenTL; cate.TenTL_KhongDau = StringHelper.ToUnsignString(category.TenTL_KhongDau); cate.ThuTu = category.ThuTu; cate.AnHien = category.AnHien; db.SaveChanges(); return(RedirectToAction("Index")); } } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } } catch { ModelState.AddModelError("", "Có lỗi khi thêm mới thông tin Thể loại! Vui lòng thử lại."); } return(View(category)); }
public ActionResult Insert() { //loaitin loaitin = new loaitin(); var model = new theloai(); model.created_at = DateTime.Now; return(View(model)); }
public ActionResult DeleteConfirmed(int id) { theloai theloai = db.theloais.Find(id); db.theloais.Remove(theloai); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult TheLoaiPartial(theloai tl) { //Thêm vào cơ sở dữ liệu if (ModelState.IsValid) { db.theloais.Add(tl); db.SaveChanges(); } return(PartialView()); }
public ActionResult Edit(theloai theloai) { if (ModelState.IsValid) { theloai.updated_at = DateTime.Now; theloai.TenKhongDau = mystring.convertToUnSign(theloai.Ten); db.Entry(theloai).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Update data successfully!"; //return RedirectToAction("Index"); } return(View(theloai)); }
// GET: Admin/Theloai/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } theloai theloai = db.theloais.Find(id); if (theloai == null) { return(HttpNotFound()); } return(View(theloai)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } theloai theloai = db.theloais.Find(id); theloai.updated_at = DateTime.Now; if (theloai == null) { return(HttpNotFound()); } return(View(theloai)); }
public List <theloai> GetHiearchyList(List <theloai> lstAll, theloai node) { var lstChilds = lstAll.Where(ds => ds.parent_maloai == node.idtheloai).ToList(); if (lstChilds.Count == 0) { return(null); } for (int i = 0; i < lstChilds.Count; i++) { var childs = GetHiearchyList(lstAll, lstChilds[i]); lstChilds[i].type = (childs == null || childs.Count == 0) ? "leaf" : ""; lstChilds[i].children = childs; } return(lstChilds.OrderBy(s => s.idtheloai).ToList()); }
public ActionResult Delete(int?id) { int res; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } res = mod.Delete_Loaitin_Tintuc(id); //delete loaitin & tintuc theloai theloai = db.theloais.Find(id); db.theloais.Remove(theloai); db.SaveChanges(); ViewBag.Message = "Delete data successfully!"; return(RedirectToAction("Trash", "Theloai")); }
public ActionResult Deltrash(int?id) { int res; if (id == null) { return(RedirectToAction("Index")); } theloai theloai = db.theloais.Find(id); theloai.status = 0; db.Entry(theloai).State = EntityState.Modified; db.SaveChanges(); res = mod.Update_Status_LT(id, 0); //update loaitin & tintuc return(RedirectToAction("Index")); }
public ActionResult Retrash(int?id) { int res; if (id == null) { return(RedirectToAction("Trash", "Theloai")); } theloai theloai = db.theloais.Find(id); theloai.status = 2; db.Entry(theloai).State = EntityState.Modified; db.SaveChanges(); res = mod.Update_Status_LT(id, 2); //update loaitin & tintuc ViewBag.Message = "Data recovery success!"; return(RedirectToAction("Trash", "Theloai")); }
public bool Update(theloai model) { string msgError = ""; try { var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "tl_theloai_update", "@idtheloai", model.idtheloai, "@tentheloai", model.tentheloai); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
public ActionResult Insert(theloai theloai) { if (ModelState.IsValid) { if (theloai.Ten != null) { ViewBag.tam = 1; theloai.created_at = DateTime.Now; theloai.updated_at = null; theloai.TenKhongDau = mystring.convertToUnSign(theloai.Ten); db.theloais.Add(theloai); db.SaveChanges(); ViewBag.Message = "Add data successfully!"; } else { ViewBag.tam = 2; ViewBag.Message = "The input data is empty!"; } } return(View(theloai)); }
public ActionResult Status(int?id) { int res; if (id == null) { return(RedirectToAction("Index")); } theloai theloai = db.theloais.Find(id); if (theloai.status == 1) { theloai.status = 2; res = mod.Update_Status_LT(id, 2); } else { theloai.status = 1; res = mod.Update_Status_LT(id, 1); } db.Entry(theloai).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <TheLoaiDTO> GetById(object id) { theloai theLoai = await _unitOfWork.TheLoaiRepository.GetById(id); return(_mapper.Map <TheLoaiDTO>(theLoai)); }
public bool Update(theloai model) { return(_res.Update(model)); }
public bool Create(theloai model) { return(_res.Create(model)); }
public theloai UpdateCategory([FromBody] theloai model) { _CategoryBusiness.Update(model); return(model); }