/// <summary> /// Tìm kiếm bản ghi có theo tham số id /// </summary> /// <param name="id"></param> /// <returns></returns> public Cat_LeaveDayType GetByIdCatLeaveDayType(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); Cat_LeaveDayType catLeaveDayType = new Cat_LeaveDayType(); catLeaveDayType = repo.GetById(id); if (catLeaveDayType.IsDelete == true) catLeaveDayType = null; return catLeaveDayType; } }
/// <summary> /// Tìm kiếm bản ghi có theo tham số id /// </summary> /// <param name="id"></param> /// <returns></returns> public Cat_LeaveDayType GetByIdCatLeaveDayType(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); Cat_LeaveDayType catLeaveDayType = new Cat_LeaveDayType(); catLeaveDayType = repo.GetById(id); if (catLeaveDayType.IsDelete == true) { catLeaveDayType = null; } return(catLeaveDayType); } }
/// <summary> /// Update thuộc tính IsDelete là true /// </summary> /// <param name="catLeaveDayTypeId"></param> /// <returns></returns> public bool DeleteCatLeaveDayType(int catLeaveDayTypeId) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); Cat_LeaveDayType catLeaveDayType = new Cat_LeaveDayType(); catLeaveDayType = repo.GetById(catLeaveDayTypeId); try { repo.Remove(catLeaveDayType); repo.SaveChanges(); return(true); } catch { return(false); } } }
/// <summary> /// Update thuộc tính IsDelete là true /// </summary> /// <param name="catLeaveDayTypeId"></param> /// <returns></returns> public bool DeleteCatLeaveDayType(int catLeaveDayTypeId) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); Cat_LeaveDayType catLeaveDayType = new Cat_LeaveDayType(); catLeaveDayType = repo.GetById(catLeaveDayTypeId); try { repo.Remove(catLeaveDayType); repo.SaveChanges(); return true; } catch { return false; } } }