Ejemplo n.º 1
0
        public async Task <bool> IsAllowEdit(EvalMasterBaseReq req)
        {
            var evalMaster = (from mt in (await GetAsync(p => p.EvalMasterId == req.EvalMasterId))
                              join p in EvalPeriodBE.GetAll() on mt.EvalPeriodId equals p.EvalPeriodId
                              select new { mt.BeEvalEmployeeId, mt.IsFinal, p.ToDate }).FirstOrDefault();

            if (evalMaster == null)
            {
                return(false);
            }
            var printMaster = await GetAsync(p => p.BeEvalEmployeeId == evalMaster.BeEvalEmployeeId &&
                                             p.IsFinal == true);

            if (printMaster.Any())
            {
                return(false);
            }
            if ((evalMaster.IsFinal ?? false) || DateTime.Now > evalMaster.ToDate.CheckDateEx())
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public async Task <List <EvalDetail> > ExeEvalDetailByMasterId(ExeEvalDetailByMasterIdReq req)
        {
            if (req == null)
            {
                return(null);
            }

            var evalMaster = (await GetAsync(p => p.BeEvalEmployeeId == req.BeEvalEmployeeId &&
                                             p.EvalEmployeeId == req.EvalEmployeeId &&
                                             p.EvalPeriodId == req.PeriodId))?.FirstOrDefault();

            if (evalMaster == null)
            {
                var obj = new EvalMaster()
                {
                    EvalPeriodId     = req.PeriodId,
                    BeEvalEmployeeId = req.BeEvalEmployeeId,
                    EvalEmployeeId   = req.EvalEmployeeId,
                    CreateBy         = req.EvalEmployeeId,
                    CreateDate       = DateTime.Now
                };
                this.Insert(obj);
                this._uoW.Save();
                evalMaster = (await GetAsync(p => p.EvalEmployeeId == req.EvalEmployeeId &&
                                             p.BeEvalEmployeeId == req.BeEvalEmployeeId &&
                                             p.EvalPeriodId == req.PeriodId))?.FirstOrDefault();
            }
            var lstCaterial = await GetEvalDetailByMasterId(new EvalMasterBaseReq()
            {
                EvalMasterId = evalMaster.EvalMasterId
            });

            if (lstCaterial != null && lstCaterial.Any())
            {
                return(lstCaterial);
            }
            else
            {
                var period = await EvalPeriodBE.GetById(new EvalPeriodBaseReq()
                {
                    EvalPeriodId = evalMaster.EvalPeriodId ?? 0
                });

                if (period == null)
                {
                    return(null);
                }
                var periodId = period.SchoolId ?? 0;
                var school   = await SchoolBE.GetById(new SchoolBaseReq()
                {
                    SchoolId = periodId
                });

                var evalStandard = (await EvalStandardBE.GetAsync(p => p.EvalTypeCode == period.EvalTypeCode &&
                                                                  p.SchoolLevelCode == school.SchoolLevelCode))?.Select(p => p.EvalStandardId).ToList();
                if (evalStandard == null)
                {
                    return(null);
                }
                var caterials    = (await EvalCriteriaBE.GetAsync(p => p.Active != false && evalStandard.Contains(p.EvalStandardId ?? 0)))?.ToList();
                var subPrincipal = _uoW.Context.Employees.FirstOrDefault(p => p.EmployeeId == req.BeEvalEmployeeId);
                if (subPrincipal != null &&
                    subPrincipal.UserGroupCode == EnumUserGroup.SubSchoolPrimary)    // nếu là hiệu phó thì lấy tiêu chí khác
                {
                    caterials = (from s in _uoW.Context.SubPrincipalCriterias
                                 join c in _uoW.Context.EvalCriterias on s.EvalCriteriaId equals c.EvalCriteriaId
                                 where c.Active != false && s.EvalPeriodId == req.PeriodId && s.SubPrincipalId == req.BeEvalEmployeeId
                                 select c)?.ToList();
                }



                if (caterials == null)
                {
                    return(null);
                }
                foreach (var item in caterials)
                {
                    var objDt = new EvalDetail()
                    {
                        EvalMasterId     = evalMaster.EvalMasterId,
                        EvalStandardId   = item.EvalStandardId,
                        EvalStandardName = (await EvalStandardBE.GetById(new EvalStandardBaseReq()
                        {
                            EvalStandardId = item.EvalStandardId.CheckInt()
                        }))?.EvalStandardName,
                        EvalCriteriaId   = item.EvalCriteriaId,
                        EvalCriteriaName = item.EvalCriteriaName,
                    };
                    EvalDetailBE.Insert(objDt);
                }
                //Luu cac detail
                if (!_uoW.Save())
                {
                    return(null);
                }

                return(await GetEvalDetailByMasterId(new EvalMasterBaseReq()
                {
                    EvalMasterId = evalMaster.EvalMasterId
                }));
            }
        }