public CCCommandProcessingDetailViewModel GetCommandProcessingDetails(Guid costCentreId, Guid applicationId,
     int currentPageIndex, int pageSize, CommandProcessingStatus status, out int count)
 {
     var costCentre = _costCentreRepository.GetById(costCentreId);
     var items = _commandProcessingAuditRepository.GetByApplicationId(applicationId, currentPageIndex, pageSize, status, out count);
     var vm = new CCCommandProcessingDetailViewModel(costCentre, items);
     vm.Items = vm.Items.ToList();
     return vm;
 }
 public CCCommandProcessingDetailViewModel GetCommandAuditDetails(Guid costCentreId, Guid costCentreAppId, int pageIndex, int pageSize, out int count)
 {
     var costCentre = _costCentreRepository.GetById(costCentreId);
     var items = _commandProcessingAuditRepository.GetByApplicationId(costCentreAppId, pageIndex, pageSize, 0, out count);
     var xs = items.GroupBy(n => n.ParentDocumentId);
     var groupItems = (from x in xs
                       let item = x.First()
                       let createCommand = x.FirstOrDefault(n => n.CommandType.Contains("Create"))
                       select new CommandProcessingAuditGroup
                                  {
                                      DocumentId = x.Key, 
                                      NoOfCommands = x.Count(), 
                                      DateInserted = item.DateInserted, 
                                      DateDelivered = item.DateInserted, 
                                      DocumentType = createCommand.CommandType.Remove(0, 6)
                                  }).ToList();
     count = groupItems.Count();
     var vm = new CCCommandProcessingDetailViewModel(costCentre);
     vm.GroupItems.AddRange(groupItems);
     return vm;
 }