/// <summary> /// Lấy dữ liệu theo Id /// </summary> /// <param name="id"></param> /// <returns></returns> public Cat_DayOff GetById(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_DayOffRepository repo = new Cat_DayOffRepository(unitOfWork); var catdayoff= repo.GetById(id); if (catdayoff.IsDelete == true) catdayoff = null; return catdayoff; } }
/// <summary> /// Lấy dữ liệu theo Id /// </summary> /// <param name="id"></param> /// <returns></returns> public Cat_DayOff GetById(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_DayOffRepository repo = new Cat_DayOffRepository(unitOfWork); var catdayoff = repo.GetById(id); if (catdayoff.IsDelete == true) { catdayoff = null; } return(catdayoff); } }
/// <summary> /// Remove 1 record là chuyển trạng thái IsDelete=true /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Remove(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_DayOffRepository repo = new Cat_DayOffRepository(unitOfWork); var cat = repo.GetById(id); try { repo.Remove(cat); repo.SaveChanges(); return(true); } catch { return(false); } } }
/// <summary> /// Remove 1 record là chuyển trạng thái IsDelete=true /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Remove(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_DayOffRepository repo = new Cat_DayOffRepository(unitOfWork); var cat = repo.GetById(id); try { repo.Remove(cat); repo.SaveChanges(); return true; } catch { return false; } } }