using CloudBuilder.Core.DependencyInjection.Request; using CloudBuilder.Core.Request; using CloudBuilder.Core.Service; using Microsoft.Extensions.DependencyInjection; using CloudBuilder.Master.Service; using CloudBuilder.Core.DatabaseAccessor.Entity; using Microsoft.AspNetCore.Http; using CloudBuilder.Master.Entity; using System; using CloudBuilder.Master.Data; using CloudBuilder.Master.SearchCriteria; namespace CloudBuilder.Request.Master { public class FamilyTreeRequest : IRequest { private readonly IServiceRequest serviceRequest; public FamilyTreeRequest(IServiceRequest serviceRequest) { this.serviceRequest = serviceRequest; } public FamilyTreeData FindAllByTreeId(string treeId) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/FindAllByTreeId?treeId=" + treeId.ToString())).GetAwaiter().GetResult(); } public FamilyTreeData FindByKey(string key) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); } public class FindByCurrentPersonCompositionData2 { public string key { get; set; } public string personId { get; set; } } public FamilyTreeData FindByCurrentPerson(string key, string personId) { var compositionData = new FindByCurrentPersonCompositionData2{ key = key, personId = personId }; return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/FindByCurrentPerson", compositionData)).GetAwaiter().GetResult(); } public FamilyTreeResultData FindBySearchCriteria(FamilyTreeSearchCriteria criteria) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/FindBySearchCriteria" , criteria)).GetAwaiter().GetResult(); } public FamilyTreeData Insert(FamilyTreeData data) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/Insert" , data)).GetAwaiter().GetResult(); } public class RequestFamilyTreePermissionCompositionData2 { public string treeId { get; set; } public string currentPersonId { get; set; } } public void RequestFamilyTreePermission(string treeId, string currentPersonId) { var compositionData = new RequestFamilyTreePermissionCompositionData2{ treeId = treeId, currentPersonId = currentPersonId }; Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/RequestFamilyTreePermission", compositionData)).GetAwaiter().GetResult(); } public class ApproveFamilyTreePermissionCompositionData4 { public string treeId { get; set; } public string currentPersonId { get; set; } public string userName { get; set; } public string managerIndc { get; set; } } public void ApproveFamilyTreePermission(string treeId, string currentPersonId, string userName, string managerIndc) { var compositionData = new ApproveFamilyTreePermissionCompositionData4{ treeId = treeId, currentPersonId = currentPersonId, userName = userName, managerIndc = managerIndc }; Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/ApproveFamilyTreePermission", compositionData)).GetAwaiter().GetResult(); } public class RejectFamilyTreePermissionCompositionData3 { public string treeId { get; set; } public string currentPersonId { get; set; } public string userName { get; set; } } public void RejectFamilyTreePermission(string treeId, string currentPersonId, string userName) { var compositionData = new RejectFamilyTreePermissionCompositionData3{ treeId = treeId, currentPersonId = currentPersonId, userName = userName }; Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/RejectFamilyTreePermission", compositionData)).GetAwaiter().GetResult(); } public class BindSelfPersonCompositionData2 { public string treeId { get; set; } public string personId { get; set; } } public FamilyTreeData BindSelfPerson(string treeId, string personId) { var compositionData = new BindSelfPersonCompositionData2{ treeId = treeId, personId = personId }; return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/BindSelfPerson", compositionData)).GetAwaiter().GetResult(); } public FamilyTreeData UnbindSelfPerson(string treeId) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/UnbindSelfPerson?treeId=" + treeId.ToString())).GetAwaiter().GetResult(); } public FamilyTreeData Update(FamilyTreeData data) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/Update" , data)).GetAwaiter().GetResult(); } public void Delete(string key) { Task.Run(() => serviceRequest.PostAsync("/FamilyTree/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); } public void Deletes(string[] keys) { Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/Deletes" , keys)).GetAwaiter().GetResult(); } public string GetExchangeFactor() { return Task.Run(() => serviceRequest.PostAsJsonAsync ("/FamilyTree/GetExchangeFactor")).GetAwaiter().GetResult(); } public class ExportFamilyTreeCompositionData3 { public string treeId { get; set; } public string scope { get; set; } public string anchorPersonId { get; set; } } public FamilyTreeExchangeData ExportFamilyTree(string treeId, string scope, string anchorPersonId) { var compositionData = new ExportFamilyTreeCompositionData3{ treeId = treeId, scope = scope, anchorPersonId = anchorPersonId }; return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/ExportFamilyTree", compositionData)).GetAwaiter().GetResult(); } public class SaveExchangeFileCompositionData2 { public string fileName { get; set; } public string contentBase64 { get; set; } } public string SaveExchangeFile(string fileName, string contentBase64) { var compositionData = new SaveExchangeFileCompositionData2{ fileName = fileName, contentBase64 = contentBase64 }; return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/SaveExchangeFile", compositionData)).GetAwaiter().GetResult(); } public FamilyTreeExchangeFileInfo[] ListExchangeFiles(string treeId) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/ListExchangeFiles?treeId=" + treeId.ToString())).GetAwaiter().GetResult(); } public string ReadExchangeFile(string fileName) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/ReadExchangeFile?fileName=" + fileName.ToString())).GetAwaiter().GetResult(); } public class ImportFamilyTreeCompositionData2 { public string targetTreeId { get; set; } public FamilyTreeExchangeData data { get; set; } } public Int32 ImportFamilyTree(string targetTreeId, FamilyTreeExchangeData data) { var compositionData = new ImportFamilyTreeCompositionData2{ targetTreeId = targetTreeId, data = data }; return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/ImportFamilyTree", compositionData)).GetAwaiter().GetResult(); } public class ImportSubTreeCompositionData3 { public string targetTreeId { get; set; } public string anchorPersonId { get; set; } public FamilyTreeExchangeData data { get; set; } } public Int32 ImportSubTree(string targetTreeId, string anchorPersonId, FamilyTreeExchangeData data) { var compositionData = new ImportSubTreeCompositionData3{ targetTreeId = targetTreeId, anchorPersonId = anchorPersonId, data = data }; return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/ImportSubTree", compositionData)).GetAwaiter().GetResult(); } public FamilyTreeExchangeFileInfo[] ListBackups(string treeId) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/ListBackups?treeId=" + treeId.ToString())).GetAwaiter().GetResult(); } public class RestoreBackupCompositionData2 { public string targetTreeId { get; set; } public string backupFileName { get; set; } } public Int32 RestoreBackup(string targetTreeId, string backupFileName) { var compositionData = new RestoreBackupCompositionData2{ targetTreeId = targetTreeId, backupFileName = backupFileName }; return Task.Run(() => serviceRequest.PostAsJsonAsync("/FamilyTree/RestoreBackup", compositionData)).GetAwaiter().GetResult(); } } }