public async Task <IHttpActionResult> GetChangeRequestStaging(int changeRequestId) { DriveTypeChangeRequestStagingModel changeRequestStagingDriveTypeModel = await this._driveTypeApplicationService.GetChangeRequestStaging(changeRequestId); ChangeRequestStagingDriveTypeViewModel changeRequestStagingDriveTypeViewModel = Mapper.Map <ChangeRequestStagingDriveTypeViewModel>(changeRequestStagingDriveTypeModel); SetUpChangeRequestReview(changeRequestStagingDriveTypeViewModel.StagingItem.Status, changeRequestStagingDriveTypeViewModel.StagingItem.SubmittedBy, changeRequestStagingDriveTypeViewModel); return(Ok(changeRequestStagingDriveTypeViewModel)); }
public new async Task <DriveTypeChangeRequestStagingModel> GetChangeRequestStaging <TId>(TId changeRequestId) { var result = await ChangeRequestBusinessService.GetChangeRequestStagingByChangeRequestIdAsync <DriveType, TId>(changeRequestId); List <VehicleToDriveType> vehicleToDriveTypes = null; if (result.StagingItem.ChangeType == ChangeType.Replace.ToString()) { result.EntityStaging = result.EntityCurrent; var changeRequestIdLong = Convert.ToInt64(changeRequestId); var vehicleToDriveTypeChangeRequestItems = await this.ChangeRequestBusinessService.GetChangeRequestItemStagingsAsync(item => item.ChangeRequestId == changeRequestIdLong); if (vehicleToDriveTypeChangeRequestItems != null && vehicleToDriveTypeChangeRequestItems.Any()) { var vehicleToDriveTypeIds = vehicleToDriveTypeChangeRequestItems.Select(item => Convert.ToInt32(item.EntityId)).ToList(); vehicleToDriveTypes = await base.Repositories.GetRepositoryService <VehicleToDriveType>() .GetAsync(item => vehicleToDriveTypeIds.Any(id => id == item.Id) && item.DeleteDate == null); //1. Extract the replacement DriveType to DriveTypeid from the first deserialized vehicleToDriveTypeChangeRequestItems var vehicleToDriveType = Serializer.Deserialize <VehicleToDriveType>(vehicleToDriveTypeChangeRequestItems[0].Payload); //2. fill result.EntityStaging with the replacement DriveType details result.EntityStaging = await FindAsync(vehicleToDriveType.DriveTypeId); // 3. fill currentEntity result.EntityCurrent = await FindAsync(result.StagingItem.EntityId); } else { var vehicleToDriveTypeChangeRequestStoreItems = await this.ChangeRequestBusinessService.GetChangeRequestItemAsync(item => item.ChangeRequestId == changeRequestIdLong); if (vehicleToDriveTypeChangeRequestStoreItems != null && vehicleToDriveTypeChangeRequestStoreItems.Any()) { var vehicleToDriveTypeIds = vehicleToDriveTypeChangeRequestStoreItems.Select(item => Convert.ToInt32(item.EntityId)).ToList(); vehicleToDriveTypes = await base.Repositories.GetRepositoryService <VehicleToDriveType>() .GetAsync(item => vehicleToDriveTypeIds.Any(id => id == item.Id) && item.DeleteDate == null); //1. Extract the replacement base vehicle id from the first deserialized vehicleChangeRequestItems var vehicleToDriveType = Serializer.Deserialize <VehicleToDriveType>(vehicleToDriveTypeChangeRequestStoreItems[0].Payload); //2. fill result.EntityStaging with the replacement base vehicle details result.EntityStaging = await FindAsync(vehicleToDriveType.DriveTypeId); // 3. fill currentEntity result.EntityCurrent = await FindAsync(result.StagingItem.EntityId); } } } DriveTypeChangeRequestStagingModel staging = new DriveTypeChangeRequestStagingModel { EntityCurrent = result.EntityCurrent, EntityStaging = result.EntityStaging, //RequestorComments = result.RequestorComments, //ReviewerComments = result.ReviewerComments, Comments = result.Comments, StagingItem = result.StagingItem, ReplacementVehicleToDriveTypes = vehicleToDriveTypes, Attachments = result.Attachments }; return(staging); }