コード例 #1
0
ファイル: Cat_DayOffServices.cs プロジェクト: dtafe/vnr
 /// <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;
     }
 }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
 /// <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);
         }
     }
 }
コード例 #4
0
ファイル: Cat_DayOffServices.cs プロジェクト: dtafe/vnr
        /// <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;
                }

            }
        }