private async Task <DlMetadataDetails> SetDlBookMetaData(int bookId, UserCredential userCredential, string deviceId) { DlMetadata dlMetaData = new DlMetadata() { Email = userCredential.Email, DeviceId = deviceId, DlId = bookId }; DlMetadataDetails dlMetaDataDetails = null; //before call this function,program has ensured network available. var result = await deliveryService.DlMetadata(dlMetaData); if (result.IsSuccess) { dlMetaDataDetails = JsonConvert.DeserializeObject <DlMetadataDetails>(result.Content); if (dlMetaDataDetails != null) { var metadata = publicationAccess.GetDlBookMetedata(bookId, userCredential); if (metadata == null)//insert metadata { BookMetadata entity = new BookMetadata { BookId = bookId, ServiceCode = userCredential.ServiceCode, Email = userCredential.Email, IncludedGuideCard = JsonConvert.SerializeObject(dlMetaDataDetails.GuideCard) }; publicationAccess.InsertMetadata(entity); } else//update metadata { metadata.IncludedGuideCard = JsonConvert.SerializeObject(dlMetaDataDetails.GuideCard); publicationAccess.Update(metadata); } } } return(dlMetaDataDetails); }
public async Task <HttpResponse> DlMetadata(DlMetadata dlFileMetadata) { return(await ServiceAgent.RestFullServiceJsonRequest(base.GetTargetUri(), ServiceConfig.DL_METADATA, dlFileMetadata)); }