示例#1
0
        private protected void TesterLogicsInspection(Tester tester)
        {
            try
            {
                Inspections.TesterInspection(tester);
            }
            catch (Exception e)
            {
                throw new CasingException(true, e);
            }

            TimeSpan testerAge = DateTime.Today - tester.Birthdate;

            if (testerAge < MIN_AGE_OF_TESTER || testerAge > MAX_AGE_OF_TESTER)
            {
                throw new CasingException(true, new ArgumentException($"The tester's age is not appropriate ({(int)(MIN_AGE_OF_TESTER.Days / 365.25)} - {(int)(MAX_AGE_OF_TESTER.Days / 365.25)})."));
            }

            if (tester.YearsOfExperience > tester.AgeInYears - (MIN_AGE_OF_TESTER.Days / 365.25))// CHECK minageoftrainee? (start to count years from learn or teach?)
            {
                throw new CasingException(true, new ArgumentException($"Years of experience do not make sense according to age."));
            }

            if (0 == tester.MaxOfTestsPerWeek)
            {
                throw new CasingException(true, new ArgumentException("It is illegal for the teter to not test."));
            }

            if (tester.MaxDistanceFromAddress == 0)
            {
                throw new CasingException(true, new ArgumentException("Max Distance From Address can not get 0."));
            }
        }
示例#2
0
        private protected void TraineeLogicsInspection(Trainee trainee)
        {
            try
            {
                Inspections.TraineeInspection(trainee);
            }
            catch (Exception e)
            {
                throw new CasingException(true, e);
            }

            if (DateTime.Today - trainee.Birthdate < MIN_AGE_OF_TRAINEE)
            {
                throw new CasingException(true, new ArgumentOutOfRangeException($"This Trainee's age is not appropriate (at least {(int)(MIN_AGE_OF_TRAINEE.Days / 365.25)})."));
            }
        }
示例#3
0
        public List <Tester> TheTestersWhoLiveInTheDistance(Address address)
        {
            try
            {
                Inspections.AddressValidator(address);
            }
            catch (Exception e)
            {
                throw new CasingException(true, e);
            }

            return((from tester in dal.GetTesters()
                    where DistanceAndTime(tester.Address, address).distance < tester.MaxDistanceFromAddress
                    select tester)
                   .ToList());
        }
示例#4
0
        public IActionResult Create(MorningCheckViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var org = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName);
                if (org != null)
                {
                    var entity = new Inspections();
                    entity.InspectionId     = 0;
                    entity.OrganizationId   = org.OrganizationId;
                    entity.OrganizationName = org.Name;
                    entity.ShouldCount      = model.ShouldCount.ToString();
                    entity.ActualCount      = "0";
                    entity.UnqualifiedCount = "0";
                    entity.CreatedUser      = 0;
                    entity.Inspector        = model.Inspector;
                    entity.CreatedDate      = DateTime.Now;
                    entity.CreatedAt        = DateTime.Now;
                    entity.IsSupply         = true;
                    entity.Type             = 2;
                    entity.Sync             = 0;
                    entity.IsDifferent      = true;
                    entity.DepartmentId     = model.DepartmentId;
                    //暂无班组选择
                    entity.TeamGroupId = 0;
                    _dbITMContext.Inspections.Add(entity);
                    _dbITMContext.SaveChanges();
                    response.SetSuccess("添加成功");
                }
                else
                {
                    response.SetFailed("不存在该组织");
                }


                return(Ok(response));
            }
        }