/// <summary> /// PartInspectionStatus - is based on last inspection test result status. If there were several inspection test results on one date: /// select Accepted is exists.If doesn't exist - select the last one /// </summary> public virtual PartInspectionStatus GetPartInspectionStatus() { PartInspectionStatus status = PartInspectionStatus.Pending; if (this.InspectionTestResults != null && this.InspectionTestResults.Count > 0) { status = (this.InspectionTestResults.OrderByDescending(x => x.Order).First()).Status; } return(status); }
/// <summary> /// PartInspectionStatus - is based on last inspection test result status. If there were several inspection test results on one date: /// select Accepted is exists.If doesn't exist - select the last one /// </summary> public virtual PartInspectionStatus GetPartInspectionStatus() { PartInspectionStatus status = PartInspectionStatus.Pending; if (this.InspectionTestResults != null && this.InspectionTestResults.Count > 0) { if (this.InspectionTestResults.Where(_ => _.Date == this.InspectionTestResults.Max(x => x.Date)).Count() > 1) { List <InspectionTestResult> oneDayResults = this.InspectionTestResults.Where(_ => _.Date == this.InspectionTestResults.Max(x => x.Date)).ToList(); status = oneDayResults.Any(_ => _.Status == PartInspectionStatus.Accepted) ? PartInspectionStatus.Accepted : oneDayResults.Last().Status; } else { status = this.InspectionTestResults.Where(_ => _.Date == this.InspectionTestResults.Max(x => x.Date)).Single().Status; } } return(status); }