コード例 #1
0
ファイル: Eva_PerformanceServices.cs プロジェクト: dtafe/vnr
 /// <summary> Kiểm tra Performance có tồn tại không  </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool CheckPerformanceExist(Eva_PerformanceEntity model)
 {
     bool isExist = false;
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repoPerformance = new Eva_PerformanceRepository(unitOfWork);
         if (model != null)
         {
             var performance = repoPerformance.FindBy(p => p.IsDelete == null && p.ProfileID.Value == model.ProfileID.Value
                                                           && p.PerformanceTemplateID == model.PerformanceTemplateID
                                                           && p.PerformancePlanID == model.PerformancePlanID
                                                           && p.PeriodFromDate == model.PeriodFromDate
                                                           && p.PeriodToDate == model.PeriodToDate).FirstOrDefault();
             if (performance != null)
             {
                 isExist = true;
             }
         }
     }
     return isExist;
 }
コード例 #2
0
ファイル: Eva_PerformanceServices.cs プロジェクト: dtafe/vnr
        public bool DeletePerformance(Guid performanceId)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoPerformance = new Eva_PerformanceRepository(unitOfWork);
                var repoEvaluator = new Eva_EvaluatorRepository(unitOfWork);
                var repoPerformanceForDetail = new Eva_PerformanceForDetailRepository(unitOfWork);
                var repoPerformanceEva = new Eva_PerformanceEvaRepository(unitOfWork);
                var repoPerformanceEvaDetail = new Eva_PerformanceEvaDetailRepository(unitOfWork);
                //   var evaluatorObjs = repoEvaluator.FindBy(p => evaluators.Contains(p.EvaluatorID ?? Guid.Empty) && p.ProfileID == model.ProfileID && p.PerformanceTypeID == model.PerformanceTypeID).ToList();

                //get performance
                var performanceDelete = repoPerformance.FindBy(p => p.ID == performanceId).FirstOrDefault();
                if (performanceDelete != null)
                {
                    performanceDelete.IsDelete = true;
                    repoPerformance.SaveChanges();

                    #region xoa performanceForDetail
                    var performanceForDetailDelete =
                        repoPerformanceForDetail.FindBy(p => p.PerformanceID == performanceDelete.ID).ToList();
                    foreach (var performanceForDetail in performanceForDetailDelete)
                    {
                        performanceForDetail.IsDelete = true;
                    }
                    if (performanceForDetailDelete.Any())
                    {
                        repoPerformanceForDetail.SaveChanges();
                    }
                    #endregion

                    #region xoa eva_performanceEva

                    var performanceEvaDelete =
                        repoPerformanceEva.FindBy(p => p.PerformanceID == performanceDelete.ID).ToList();

                    foreach (var evaPerformanceEva in performanceEvaDelete)
                    {
                        evaPerformanceEva.IsDelete = true;
                    }
                    if (performanceEvaDelete.Any())
                    {
                        repoPerformanceEva.SaveChanges();
                    }

                    #endregion

                    #region xoa eva_performanceEvaDetail

                    if (performanceEvaDelete.Any())
                    {
                        foreach (var evaPerformanceEva in performanceEvaDelete)
                        {
                            var performanceEvaDetailDelete =
                                repoPerformanceEvaDetail.FindBy(p => p.PerfomanceEvaID == evaPerformanceEva.ID)
                                    .FirstOrDefault();
                            if (performanceEvaDetailDelete != null)
                            {
                                performanceEvaDetailDelete.IsDelete = true;
                            }
                        }
                        repoPerformanceEvaDetail.SaveChanges();
                    }

                    #endregion
                }
            }
            return true;
        }