public bool Delete(TrinhDoHocVanEntity trinhDoHocVanEntity) { try { this.m_UnitOfWork.TonGiaoRepository.Delete(trinhDoHocVanEntity); return true; } catch (Exception e) { System.Console.WriteLine(e.ToString()); return false; } }
public List<TrinhDoHocVanEntity> GetAll() { IEnumerable<TrinhDoHocVans> model = this.m_UnitOfWork.TrinhDoHocVanRepository.GetAll(); List<TrinhDoHocVanEntity> result = new List<TrinhDoHocVanEntity>(); foreach (var item in model) { TrinhDoHocVanEntity trinhDoHocVan = new TrinhDoHocVanEntity { Id = item.Id, MaQuyDinh = item.MaQuyDinh, TenTrinhDo = item.TenTrinhDo }; result.Add(trinhDoHocVan); } return result; }
public bool Create(TrinhDoHocVanEntity trinhDoHocVanEntity) { using (var scope = new TransactionScope()) { var trinhDoHocVan = new TrinhDoHocVans { Id = trinhDoHocVanEntity.Id, MaQuyDinh = trinhDoHocVanEntity.MaQuyDinh, TenTrinhDo = trinhDoHocVanEntity.TenTrinhDo }; m_UnitOfWork.TrinhDoHocVanRepository.Insert(trinhDoHocVan); m_UnitOfWork.Save(); scope.Complete(); return true; } }
/// only return json to client public ActionResult Create(TrinhDoHocVanEntity trinhDoHocVan) { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); if (trinhDoHocVan == null) { RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ"); return Json(JsonConvert.SerializeObject(ViewData)); } if (service.Create(trinhDoHocVan)) { return Json(RenderResult.RequestCompleted(ViewData, "Thêm dân tộc thành công")); } else { return Json(RenderResult.RequestCompleted(ViewData, "Lỗi khi thêm dân tộc")); } }
public bool Update(TrinhDoHocVanEntity trinhDoHocVanEntity) { var success = false; if (trinhDoHocVanEntity != null) { var trinhDoHocVan = m_UnitOfWork.TrinhDoHocVanRepository.GetByID(trinhDoHocVanEntity.Id); if (trinhDoHocVan != null) { trinhDoHocVan.Id = trinhDoHocVanEntity.Id; trinhDoHocVan.MaQuyDinh = trinhDoHocVanEntity.MaQuyDinh; trinhDoHocVan.TenTrinhDo = trinhDoHocVanEntity.TenTrinhDo; m_UnitOfWork.TrinhDoHocVanRepository.Update(trinhDoHocVan); m_UnitOfWork.Save(); success = true; } } return success; }
public ActionResult Delete(TrinhDoHocVanEntity trinhDoHocVan) { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); try { if (service.Delete(trinhDoHocVan)) return Json(RenderResult.RequestCompleted(ViewData, "Xóa thành công")); return Json(RenderResult.RequestCompleted(ViewData, "Xóa không thành công")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); return Json(RenderResult.RequestError(ViewData, "Lỗi xảy ra")); } }
public ActionResult Edit(TrinhDoHocVanEntity trinhDoHocVan) { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); if (trinhDoHocVan == null) { return Json(RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ"), JsonRequestBehavior.AllowGet); } try { if (service.Update(trinhDoHocVan)) return Json(RenderResult.RequestCompleted(ViewData, "Chỉnh sửa thành công")); return Json(RenderResult.RequestCompleted(ViewData, "Chỉnh sửa không thành công")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); return Json(RenderResult.RequestError(ViewData, "Lỗi xảy ra")); } }