/// <summary> /// Lấy tất cả dữ liệu /// </summary> /// <returns></returns> public IQueryable <Cat_Shift> GetAll() { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_ShiftRepository repo = new Cat_ShiftRepository(unitOfWork); return(repo.GetAllCatShift().Where(i => i.IsDelete == null)); } }
/// <summary> /// Lấy tất cả các bản ghi có thuộc tính IsDelete là null /// Gọi GetAllCatLeaveDayType() trong Cat_LeaveDayTypeRepository /// </summary> /// <returns></returns> public IQueryable<Cat_LeaveDayType> GetCatLeaveDayType() { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); return repo.GetAllCatLeaveDayType().Where(i => i.IsDelete == null); } }
/// <summary> /// Lấy dữ liệu theo Id /// </summary> /// <param name="id"></param> /// <returns></returns> public Cat_Shift GetById(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_ShiftRepository repo = new Cat_ShiftRepository(unitOfWork); var catshift= repo.GetById(id); if (catshift.IsDelete == true) catshift = null; return catshift; } }
/// <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> /// 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> /// Lấy dữ liệu theo Id /// </summary> /// <param name="id"></param> /// <returns></returns> public Cat_Shift GetById(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_ShiftRepository repo = new Cat_ShiftRepository(unitOfWork); var catshift = repo.GetById(id); if (catshift.IsDelete == true) { catshift = null; } return(catshift); } }
/// <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> /// 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> /// Thêm bản ghi mới /// </summary> /// <param name="catLeaveDayType"></param> /// <returns></returns> public bool AddCatLeaveDayType(Cat_LeaveDayType catLeaveDayType) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); try { repo.Add(catLeaveDayType); repo.SaveChanges(); return true; } catch { return false; } } }
/// <summary> /// Edit một record /// </summary> /// <param name="cat"></param> /// <returns></returns> public bool Edit(Cat_Shift cat) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_ShiftRepository repo = new Cat_ShiftRepository(unitOfWork); try { repo.Edit(cat); repo.SaveChanges(); return(true); } catch { return(false); } } }
/// <summary> /// Update bản ghi /// </summary> /// <param name="catLeaveDayType"></param> /// <returns></returns> public bool UpdateCatLeaveDayType(Cat_LeaveDayType catLeaveDayType) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); try { repo.Edit(catLeaveDayType); 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_ShiftRepository repo = new Cat_ShiftRepository(unitOfWork); var cat = repo.GetById(id); try { repo.Remove(cat); repo.SaveChanges(); return(true); } catch { return(false); } } }
/// <summary> /// Edit một record /// </summary> /// <param name="cat"></param> /// <returns></returns> public bool Edit(Cat_Shift cat) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_ShiftRepository repo = new Cat_ShiftRepository(unitOfWork); try { repo.Edit(cat); 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); } } }
/// <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> /// 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_ShiftRepository repo = new Cat_ShiftRepository(unitOfWork); var cat = repo.GetById(id); try { repo.Remove(cat); repo.SaveChanges(); return true; } catch { return false; } } }