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 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(); } } }