public List <MissionsWorkflowDocumentsViewModels> GetWorkFlowMissionDocuments(int missionId) { string descriptionTor = "TOR v"; var viewDocuments = _missionService.GetDocuments(missionId).MissionDocuments; var listDocument = new List <MissionsWorkflowDocumentsViewModels>(); var listDocumentTor = new List <MissionsWorkflowDocumentsViewModels>(); foreach (var item in viewDocuments) { var missionDocument = new MissionsWorkflowDocumentsViewModels() { //DocNumber = Convert.ToInt32(item.Document.DocumentReference), DocumentNumber = item.Document.DocumentReference, Date = item.Document.Created.Value, Description = item.Document.Description, User = item.Document.CreatedBy }; if ((missionDocument.Description.Length >= 5) && missionDocument.Description.Substring(0, 5).Equals(descriptionTor)) { listDocumentTor.Add(missionDocument); } } if (listDocumentTor.Count > 0) { IEnumerable <MissionsWorkflowDocumentsViewModels> listDocuments = listDocumentTor.OrderByDescending(x => x.DocNumber); foreach (var item in listDocuments) { listDocument.Add(item); } } foreach (var item in viewDocuments) { var missionDocument = new MissionsWorkflowDocumentsViewModels() { //DocNumber = Convert.ToInt32(item.Document.DocumentReference), DocumentNumber = item.Document.DocumentReference, Date = item.Document.Created.Value, Description = item.Document.Description, User = item.Document.CreatedBy }; if ((missionDocument.Description.Length <= 5) || (missionDocument.Description.Substring(0, 5) != descriptionTor)) { listDocument.Add(missionDocument); } } return(listDocument); }