partial void Issues_Validate(Issue entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.TargetResolutionDate != null & entity.DateRaised != null)
            {
                if (entity.TargetResolutionDate < entity.DateRaised)
                {
                    results.AddEntityError("The target date cannot be earlier than the date raised");
                }
            }

            if (entity.TargetResolutionDate != null & entity.CorrectiveActionCompletionTargetDate != null)
            {
                if (entity.TargetResolutionDate < entity.CorrectiveActionCompletionTargetDate)
                {
                    results.AddEntityError("The corrective action must be completed on or before the target resolution date");
                }
            }

            if (entity.TargetResolutionDate != null & entity.PreventativeActionCompletionTargetDate != null)
            {
                if (entity.TargetResolutionDate < entity.PreventativeActionCompletionTargetDate)
                {
                    results.AddEntityError("The preventative action must be completed on or before the target resolution date");
                }
            }
        }
Esempio n. 2
0
        partial void Issues_Validate(Issue entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.TargetResolutionDate != null & entity.DateRaised != null)
            {
                if (entity.TargetResolutionDate < entity.DateRaised)
                {
                    results.AddEntityError("The target date cannot be earlier than the date raised");
                }
            }

            if (entity.TargetResolutionDate != null & entity.CorrectiveActionCompletionTargetDate != null)
            {
                if (entity.TargetResolutionDate < entity.CorrectiveActionCompletionTargetDate)
                {
                    results.AddEntityError("The corrective action must be completed on or before the target resolution date");
                }
            }

            if (entity.TargetResolutionDate != null & entity.PreventativeActionCompletionTargetDate != null)
            {
                if (entity.TargetResolutionDate < entity.PreventativeActionCompletionTargetDate)
                {
                    results.AddEntityError("The preventative action must be completed on or before the target resolution date");
                }
            }
        }
partial         void Enrollments_Validate(Enrollment entity, EntitySetValidationResultsBuilder results)
        {
            // If the section has reached the max enrollment limit, show an error
            if (entity.Section.SpaceRemaining < 0)
            {
                results.AddEntityError("This section is full.");
            }
        }
Esempio n. 4
0
 partial void Enrollments_Validate(Enrollment entity, EntitySetValidationResultsBuilder results)
 {
     // If the section has reached the max enrollment limit, show an error
     if (entity.Section.SpaceRemaining < 0)
     {
         results.AddEntityError("This section is full.");
     }
 }
        partial void Assets_Validate(Asset entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.CommissionDate != null & entity.PurchaseDate != null)
            {
                if (entity.CommissionDate < entity.PurchaseDate)
                {
                    results.AddEntityError("An Asset cannot be commissioned before it is purchased");
                }
            }

            if (entity.IntendedReplacementDate != null & entity.PurchaseDate != null)
            {
                if (entity.IntendedReplacementDate < entity.PurchaseDate)
                {
                    results.AddEntityError("An Asset cannot be replaced before it is purchased");
                }
            }

            if (entity.IntendedReplacementDate != null & entity.CommissionDate != null)
            {
                if (entity.IntendedReplacementDate < entity.CommissionDate)
                {
                    results.AddEntityError("An Asset cannot be replaced before it is commissioned");
                }
            }

            if (entity.DateRemovedFromUse != null & entity.PurchaseDate != null)
            {
                if (entity.DateRemovedFromUse < entity.PurchaseDate)
                {
                    results.AddEntityError("An Asset cannot be removed from use before it is purchased");
                }
            }

            if (entity.DateRemovedFromUse != null & entity.CommissionDate != null)
            {
                if (entity.DateRemovedFromUse < entity.CommissionDate)
                {
                    results.AddEntityError("An Asset cannot be removed from use before it is commissioned");
                }
            }

            if (entity.DateCurrentValueEvaluated != null & entity.PurchaseDate != null)
            {
                if (entity.DateCurrentValueEvaluated < entity.PurchaseDate)
                {
                    results.AddEntityError("An Asset value cannot be evaluated before it is purchased");
                }
            }

            if (entity.DateCurrentValueEvaluated != null & entity.CommissionDate != null)
            {
                if (entity.DateCurrentValueEvaluated < entity.CommissionDate)
                {
                    results.AddEntityError("An Asset value cannot be evaluated before it is commissioned");
                }
            }
        }
Esempio n. 6
0
 //<Snippet4>
 partial void Orders_Validate
     (Order entity, EntitySetValidationResultsBuilder results)
 {
     if (!CustomerCreditApproval(entity.Customer))
     {
         results.AddEntityError
             ("Customer Credit has not yet been approved");
     }
 }
Esempio n. 7
0
 partial void Audits_Validate(Audit entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateCompleted != null & entity.DateStarted != null)
     {
         if (entity.DateCompleted < entity.DateStarted)
         {
             results.AddEntityError("An audit cannot be completed before it has started");
         }
     }
 }
 partial void Audits_Validate(Audit entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateCompleted != null & entity.DateStarted != null)
     {
         if (entity.DateCompleted < entity.DateStarted)
         {
             results.AddEntityError("An audit cannot be completed before it has started");
         }
     }
 }
Esempio n. 9
0
 partial void AuditFindings_Validate(AuditFinding entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateFindingClosed != null & entity.FindingDate != null)
     {
         if (entity.DateFindingClosed < entity.FindingDate)
         {
             results.AddEntityError("An audit finding cannot be closed before it is opened");
         }
     }
 }
 partial void ProjectTasks_Validate(ProjectTask entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateCompleted != null & entity.DateStarted != null)
     {
         if (entity.DateCompleted < entity.DateStarted)
         {
             results.AddEntityError("A Project Task cannot be completed before it has been started");
         }
     }
 }
 partial void Projects_Validate(Project entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.EndDate != null & entity.StartDate != null)
     {
         if (entity.EndDate < entity.StartDate)
         {
             results.AddEntityError("A Project cannot be finished before it has started");
         }
     }
 }
 partial void OrderDetails_Validate(OrderDetail entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateOrderShipped != null & entity.Order.OrderDate != null)
     {
         if (entity.DateOrderShipped < entity.Order.OrderDate)
         {
             results.AddEntityError("The order cannot be shipped before it is placed");
         }
     }
 }
 partial void PurchaseOrderDetails_Validate(PurchaseOrderDetail entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateRecieved != null & entity.PurchaseOrder.DatePurchaseOrderPlaced != null)
     {
         if (entity.DateRecieved < entity.PurchaseOrder.DatePurchaseOrderPlaced)
         {
             results.AddEntityError("The purchase order product cannot be recieved before the purchase order is placed");
         }
     }
 }
 partial void Orders_Validate(Order entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.OrderDate != null & entity.DatePaid != null)
     {
         if (entity.DatePaid < entity.OrderDate)
         {
             results.AddEntityError("The order cannot be paid foe before it is placced");
         }
     }
 }
 partial void EmployeeGroupCourseAssignments_Validate(EmployeeGroupCourseAssignment entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.TargetCompletionDate != null & entity.DateAssigned != null)
     {
         if (entity.TargetCompletionDate < entity.DateAssigned)
         {
             results.AddEntityError("The target date cannot be earlier than the assigned date");
         }
     }
 }
Esempio n. 16
0
        partial void SurveyQuestions_Validate(SurveyQuestion entity, EntitySetValidationResultsBuilder results)
        {
            var surveyId = entity.Survey.Id;
            var question = SurveyQuestions.Where(q => q.Survey.Id == surveyId && q.Question == entity.Question).FirstOrDefault();

            if (question != null)
            {
                results.AddEntityError("Question already exists for this survey!");
            }
        }
 partial void AuditFindings_Validate(AuditFinding entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateFindingClosed != null & entity.FindingDate != null)
     {
         if (entity.DateFindingClosed < entity.FindingDate)
         {
             results.AddEntityError("An audit finding cannot be closed before it is opened");
         }
     }
 }
Esempio n. 18
0
 partial void RiskAssessments_Validate(RiskAssessment entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateApproved != null & entity.DateEffective != null)
     {
         if (((DateTime)entity.DateEffective).Date < ((DateTime)entity.DateApproved).Date)
         {
             results.AddEntityError("A Risk Assessment cannot be effective until it has been approved");
         }
     }
 }
Esempio n. 19
0
 partial void BooksForDocuments_Validate(BooksForDocument entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.Book.Quantity <= entity.Quantity)
     {
         if (entity.Quantity <= 0)
         {
             results.AddEntityError("You can't send 0 or less books to a bookstore");
         }
         results.AddEntityError("Not enough books in warehouse");
     }
 }
Esempio n. 20
0
        partial void si_meeting_decisions_Validate(si_meeting_decision entity, EntitySetValidationResultsBuilder results)
        {
            ///Not using because unable to differentiate between update and insert event
            ///

            //var ds = applicationExists(entity.si_applications.Id, entity.si_meeting.Id);

            //if(ds.Count()>0)
            //{
            //    results.AddPropertyError(entity.ApplicationID + " is a Duplicate Entry", entity.Details.Properties.si_applications);
            //}
        }
        partial void WorkTimeSet_Validate(WorkTime entity, EntitySetValidationResultsBuilder results)
        {
            DateTime startTime;
            DateTime endTime;

            if (!string.IsNullOrEmpty(entity.StartTime) && !DateTime.TryParseExact(entity.StartTime, "HH:mm", null, System.Globalization.DateTimeStyles.None, out startTime))
            {
                results.AddPropertyError("開始時刻形式が不正", entity.Details.Properties.StartTime);
            }
            if (!string.IsNullOrEmpty(entity.EndTime) && !DateTime.TryParseExact(entity.EndTime, "HH:mm", null, System.Globalization.DateTimeStyles.None, out endTime))
            {
                results.AddPropertyError("終了時刻形式が不正", entity.Details.Properties.EndTime);
            }
        }
partial         void Clients_Validate(Client entity, EntitySetValidationResultsBuilder results)
        {
            int frequency = 0;

            // Check if sponsor relationship has only 1 primary contact item
            foreach (SponsorRelationship s in entity.SponsorRelationship)
                if (s.IsPrimary == true)
                    frequency++;

            //To-do: Add a resource file with BUSINESS RULE validation dictionary thats hold ALL constant string messages. P2 S1
            if ( frequency == 0 )
               results.AddEntityError("[Business Rule] A Client must have a sponsor list with one sponsor as primary contact. Please add only one sponsor with a primary contact.");
            else if ( frequency >= 2)
               results.AddEntityError("[Business Rule] A Client may have more than one sponsors relationship but must have only one sponsor as primary contact with only.  Please ensure that one sponsor exist with column 'Is Primary' with only one 'true' value.");
        }
Esempio n. 23
0
        partial void FindingActions_Validate(FindingAction entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.ActionTargetCompletionDate != null & entity.DateActionAssigned != null)
            {
                if (entity.ActionTargetCompletionDate < entity.DateActionAssigned)
                {
                    results.AddEntityError("An audit finding action cannot have a target date earlier than the assigned date");
                }
            }

            if (entity.ActionTargetCompletionDate != null & entity.DateActionAssigned != null)
            {
                if (entity.DateActionCompleted < entity.DateActionAssigned)
                {
                    results.AddEntityError("An audit finding action cannot be completed before it is assigned");
                }
            }
        }
        partial void FurtherActions_Validate(FurtherAction entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.Issue.TargetResolutionDate != null & entity.TargetCompletionDate != null)
            {
                if (entity.Issue.TargetResolutionDate < entity.TargetCompletionDate)
                {
                    results.AddEntityError("The target date for this further action cannot be latter than the overall target date for the issue");
                }
            }

            if (entity.TargetCompletionDate != null & entity.DateAssigned != null)
            {
                if (entity.TargetCompletionDate < entity.DateAssigned)
                {
                    results.AddEntityError("The target date cannot be earlier than the date assigned");
                }
            }
        }
        partial void ChangeRequests_Validate(ChangeRequest entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.TargetClosureDate != null & entity.DateRaised != null)
            {
                if (entity.TargetClosureDate < entity.DateRaised)
                {
                    results.AddEntityError("The target closure date cannot be before the date raised");
                }
            }

            if (entity.DateClosed != null & entity.DateRaised != null)
            {
                if (entity.DateClosed < entity.DateRaised)
                {
                    results.AddEntityError("The date closed cannot be before the date raised");
                }
            }
        }
        partial void PurchaseOrders_Validate(PurchaseOrder entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.DatePurchaseOrderPlaced != null & entity.DatePurchaseOrderRequired != null)
            {
                if (entity.DatePurchaseOrderRequired < entity.DatePurchaseOrderPlaced)
                {
                    results.AddEntityError("The order required date cannot be earlier than the date order placed");
                }
            }

            if (entity.DatePurchaseOrderPlaced != null & entity.DatePurchaseOrderShipped != null)
            {
                if (entity.DatePurchaseOrderShipped < entity.DatePurchaseOrderPlaced)
                {
                    results.AddEntityError("The shipped date cannot be earlier than the date order placed");
                }
            }
        }
Esempio n. 27
0
        partial void FurtherActions_Validate(FurtherAction entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.Issue.TargetResolutionDate != null & entity.TargetCompletionDate != null)
            {
                if (entity.Issue.TargetResolutionDate < entity.TargetCompletionDate)
                {
                    results.AddEntityError("The target date for this further action cannot be latter than the overall target date for the issue");
                }
            }

            if (entity.TargetCompletionDate != null & entity.DateAssigned != null)
            {
                if (entity.TargetCompletionDate < entity.DateAssigned)
                {
                    results.AddEntityError("The target date cannot be earlier than the date assigned");
                }
            }
        }
Esempio n. 28
0
        partial void Issues_Validate(Issue entity, EntitySetValidationResultsBuilder results)
        {
            //Listing 5-6. Validating the Counts of Child Items
            if (entity.IssueDocuments.Count() > 10)
            {
                results.AddEntityError(
                    "Issues can only contain a maximum of 10 documents");
            }

            //Listing 5-10. Validating Deletions on the Server
            if (entity.Details.EntityState == EntityState.Deleted)
            {
                if (entity.IssueResponses.Where(s => s.AwaitingClient).Any())
                {
                    results.AddEntityError(
                        "Cannot delete issues with responses awaiting client.");
                }
            }
        }
        partial void ServiceContracts_Validate(ServiceContract entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.EndDate != null & entity.StartDate != null)
            {
                if (entity.EndDate < entity.StartDate)
                {
                    results.AddEntityError("A Service Contract cannot end before it has started");
                }
            }

            if (entity.CurrentContract == true)
            {
                var existingCurrentContractsCount = (from serviceContract in DataWorkspace.ApplicationData.ServiceContracts
                                                     where (serviceContract.ServiceContractSupplier.Id == entity.ServiceContractSupplier.Id &&
                                                            serviceContract.Id != entity.Id) && serviceContract.CurrentContract == true
                                                     select serviceContract).Execute().Count();

                if (existingCurrentContractsCount > 0)
                {
                    results.AddEntityError("There is already a current contract for this supplier. Change and save that first.");
                }
            }
        }
Esempio n. 30
0
partial         void Opportunities_Validate(Opportunity entity, EntitySetValidationResultsBuilder results)
        {
        }
 partial void Projects_Validate(Project entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.EndDate != null & entity.StartDate != null)
     {
         if (entity.EndDate < entity.StartDate)
         {
             results.AddEntityError("A Project cannot be finished before it has started");
         }
     }
 }
 partial void ProjectTasks_Validate(ProjectTask entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateCompleted != null & entity.DateStarted != null)
     {
         if (entity.DateCompleted < entity.DateStarted)
         {
             results.AddEntityError("A Project Task cannot be completed before it has been started");
         }
     }
 }
        partial void ChangeRequests_Validate(ChangeRequest entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.TargetClosureDate != null & entity.DateRaised != null)
            {
                if (entity.TargetClosureDate < entity.DateRaised)
                {
                    results.AddEntityError("The target closure date cannot be before the date raised");
                }
            }

            if (entity.DateClosed != null & entity.DateRaised != null)
            {
                if (entity.DateClosed < entity.DateRaised)
                {
                    results.AddEntityError("The date closed cannot be before the date raised");
                }
            }
        }
partial         void SponsorRelationship_Validate(SponsorRelationship entity, EntitySetValidationResultsBuilder results)
        {
        }
 partial void PurchaseOrderDetails_Validate(PurchaseOrderDetail entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateRecieved != null & entity.PurchaseOrder.DatePurchaseOrderPlaced != null)
     {
         if (entity.DateRecieved < entity.PurchaseOrder.DatePurchaseOrderPlaced)
         {
             results.AddEntityError("The purchase order product cannot be recieved before the purchase order is placed");
         }
     }
 }
        partial void EmployeeTrainingRecords_Validate(EmployeeTrainingRecord entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.TargetCompletionDate != null & entity.DateAssigned != null)
            {
                if (entity.TargetCompletionDate < entity.DateAssigned)
                {
                    results.AddEntityError("The target date cannot be earlier than the assigned date");
                }
            }

            if (entity.DateTrainingCompleted != null & entity.DateTrainingCommenced != null)
            {
                if (entity.DateTrainingCompleted < entity.DateTrainingCommenced)
                {
                    results.AddEntityError("Training cannot be completed before it has commenced");
                }
            }
        }
        //partial void SearchActivity_PreprocessQuery(DateTime? FromDate, DateTime? ToDate, int? SchoolPartDistrictId, string SearchText, ref IQueryable<Activity> query)
        //{
        //    if (SearchText != null && SearchText != "")
        //    {
        //        //IEnumerable<SchoolPart> schoolParts = this.SchoolParts.Search(new SearchTerm(SearchText)).Execute();
        //        //IEnumerable<Topic> topics = this.Topics.Search(new SearchTerm(SearchText)).Execute();
        //        //IEnumerable<ActivityType> activityTypes = this.ActivityTypes.Search(new SearchTerm(SearchText)).Execute();
        //        //IEnumerable<City> cities = this.Cities.Search(new SearchTerm(SearchText)).Execute();
        //        //IEnumerable<Counselor> counselors = this.Counselors.Search(new SearchTerm(SearchText)).Execute();
        //        //IEnumerable<Contact> contacts = this.Contacts.Search(new SearchTerm(SearchText)).Execute();

        //        Func<Activity,bool> method = CreateDelegate(SearchText);


        //        query = query.Where(
        //            a => a.SchoolPart!= null.FullName.Contains(SearchText) ||
        //                 a.Topic.topics.Contains(a.Topic) ||
        //                 activityTypes.Contains(a.ActivityType) ||
        //                 (a.SchoolPart!=null && cities.Contains(a.SchoolPart.City)) ||
        //                 a.AssignedCounselors.Contains(SearchText) ||
        //                 contacts.Contains(a.Contact)

        //            );
        //    }
        //}

        //private bool Pass(string search, List<EntityObject> obj)
        //{

        //}




        //partial void SearchActivity_PreprocessQuery(DateTime? FromDate, DateTime? ToDate, int? SchoolPartDistrictId, string SearchText, ref IQueryable<Activity> query)
        //{
        //    List<SchoolPart> schoolsPart = this.SchoolParts.Where(s => s.SchoolName.Contains(SearchText)).Execute().ToList();

        //    if (SearchText != null && SearchText != "")
        //    {

        //        query = query.Where(
        //            a => a.DataForSearch.Contains(a.SchoolPart)
        //                 //a.Topic!=null && a.Topic.Title.Contains(SearchText) ||
        //                 //a.ActivityType !=null && a.ActivityType.T.Contains(SearchText) ||
        //                 //a.SchoolPart != null && a.SchoolPart.City!=null && a.SchoolPart.City.Title.Contains(SearchText) ||
        //                 //a.AssignedCounselors.Contains(SearchText) ||
        //                 //a.Contact!=null && a.Contact.FullName.Contains(SearchText)
        //            );
        //    }
        //}


        partial void Activities_Validate(Activity entity, EntitySetValidationResultsBuilder results)
        {
            
            //if (entity.Contact != null && entity.Contact.SchoolPart.Id !=entity.SchoolPart.Id)
            //{
            //    results.AddEntityError("איש הקשר שנבחר לא תואם את בית הספר שנבחר");
            //}
            //if (entity.Contact == null && entity.SchoolPart == null)
            //{
            //    results.AddEntityError("חייבים לבחור אחד מבין השדות הבאים : בית ספר, איש קשר");
            //}
            //else if (entity.SchoolPart == null)
            //{
            //    entity.SchoolPart = entity.Contact.SchoolPart;
            //}

            //if (entity.Topic != null)
            //{
            //    entity.ActivityType = entity.Topic.TopicCollection.ActivityType;
            //}

            
        }
        partial void FindingActions_Validate(FindingAction entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.ActionTargetCompletionDate != null & entity.DateActionAssigned != null)
            {
                if (entity.ActionTargetCompletionDate < entity.DateActionAssigned)
                {
                    results.AddEntityError("An audit finding action cannot have a target date earlier than the assigned date");
                }
            }

            if (entity.ActionTargetCompletionDate != null & entity.DateActionAssigned != null)
            {
                if (entity.DateActionCompleted < entity.DateActionAssigned)
                {
                    results.AddEntityError("An audit finding action cannot be completed before it is assigned");
                }
            }
        }
 partial void RiskAssessments_Validate(RiskAssessment entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateApproved != null & entity.DateEffective != null)
     {
         if (((DateTime)entity.DateEffective).Date < ((DateTime)entity.DateApproved).Date)
         {
             results.AddEntityError("A Risk Assessment cannot be effective until it has been approved");
         }
     }
 }
        partial void PurchaseOrders_Validate(PurchaseOrder entity, EntitySetValidationResultsBuilder results)
        {
            if (entity.DatePurchaseOrderPlaced != null & entity.DatePurchaseOrderRequired != null)
            {
                if (entity.DatePurchaseOrderRequired < entity.DatePurchaseOrderPlaced)
                {
                    results.AddEntityError("The order required date cannot be earlier than the date order placed");
                }
            }

            if (entity.DatePurchaseOrderPlaced != null & entity.DatePurchaseOrderShipped != null)
            {
                if (entity.DatePurchaseOrderShipped < entity.DatePurchaseOrderPlaced)
                {
                    results.AddEntityError("The shipped date cannot be earlier than the date order placed");
                }
            }
        }
 partial void OrderDetails_Validate(OrderDetail entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateOrderShipped != null & entity.Order.OrderDate != null)
     {
         if (entity.DateOrderShipped < entity.Order.OrderDate)
         {
             results.AddEntityError("The order cannot be shipped before it is placed");
         }
     }
 }
 partial void TrainingSessions_Validate(TrainingSession entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.EndDate != null & entity.StartDate != null)
     {
         if (entity.EndDate < entity.StartDate)
         {
             results.AddEntityError("The session cannot end before it has started");
         }
     }
 }
        partial void TrainingSessionAttendees_Validate(TrainingSessionAttendee entity, EntitySetValidationResultsBuilder results)
        {
            var session = this.DataWorkspace.ApplicationData.TrainingSessions.Where(s => s.Id == entity.TrainingSession.Id).FirstOrDefault();
            session.TrainingSessionAttendees.Count();


            if (session.MaximumAttendees < session.TrainingSessionAttendees.Count() + 1)
            {
                results.AddEntityError("The maximum number of attendees has been reached for this session.");
            }
        }
 partial void Orders_Validate(Order entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.OrderDate != null & entity.DatePaid != null)
     {
         if (entity.DatePaid < entity.OrderDate)
         {
             results.AddEntityError("The order cannot be paid foe before it is placced");
         }
     }
 }
 partial void AssetMaintenanceActivities_Validate(AssetMaintenanceActivity entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.DateCompleted != null & entity.DateDue != null)
     {
         if (entity.DateCompleted < entity.DateDue)
         {
             results.AddEntityError("An activity cannot be comleted before it has started");
         }
     }
 }