コード例 #1
0
        private LoadtestValidationSummary OkToAddOrModify(Loadtest loadtest)
        {
            var validationSummary = new LoadtestValidationSummary
            {
                OkToAddOrModify            = true,
                ReasonForValidationFailure = string.Empty
            };

            var loadtestsOnSameAgent = (from l in Loadtests
                                        where l.AgentId == loadtest.AgentId &&
                                        DatesOverlap(l, loadtest)
                                        select l)
                                       .ToList();

            if (loadtestsOnSameAgent.Count >= 2)
            {
                validationSummary.OkToAddOrModify             = false;
                validationSummary.ReasonForValidationFailure +=
                    " The selected load test agent is already booked for this period. ";
            }

            if (loadtest.EngineerId.HasValue)
            {
                var loadtestsOnSameEngineer = (from l in Loadtests
                                               where l.EngineerId.Value == loadtest.EngineerId.Value &&
                                               DatesOverlap(l, loadtest)
                                               select l)
                                              .ToList();

                if (loadtestsOnSameEngineer.Any())
                {
                    validationSummary.OkToAddOrModify             = false;
                    validationSummary.ReasonForValidationFailure +=
                        " The selected load test engineer is already booked for this period. ";
                }
            }

            return(validationSummary);
        }
コード例 #2
0
 private bool DatesOverlap(Loadtest loadtestOne, Loadtest loadtestTwo)
 {
     return(loadtestOne.Parameters.StartDateUtc < loadtestTwo.Parameters.GetEndDateUtc() &&
            loadtestTwo.Parameters.StartDateUtc < loadtestOne.Parameters.GetEndDateUtc());
 }