using CloudBuilder.Core.DependencyInjection.Request;
using CloudBuilder.Core.Request;
using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.Security.Service;
            using CloudBuilder.Core.DatabaseAccessor.Entity;
            using Microsoft.AspNetCore.Http;
            using CloudBuilder.Core.Policy;
            using CloudBuilder.Core.DependencyInjection.Request;
            using CloudBuilder.Security.Data;
            using CloudBuilder.Core.Authorization;
            using CloudBuilder.Security.Entity;
            using CloudBuilder.Security.SearchCriteria;
            using CloudBuilder.Security;
            using System;
            
namespace CloudBuilder.Request.Security
{

public class SecurityUserRequest : IRequest
{

private readonly IServiceRequest serviceRequest;
public SecurityUserRequest(IServiceRequest serviceRequest)
{
this.serviceRequest = serviceRequest;
}

        public  SecurityUserEntity FindByStaffId(string staffid)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<SecurityUserEntity>("/SecurityUser/FindByStaffId?staffid=" + staffid.ToString())).GetAwaiter().GetResult();                }

                        public  SecurityUserData FindByKey(string key)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<SecurityUserData>("/SecurityUser/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult();                }

                        public   SecurityUserEntity[] FindAll()
                {
return  Task.Run(() =>  serviceRequest.PostAsJsonAsync<SecurityUserEntity[]> ("/SecurityUser/FindAll")).GetAwaiter().GetResult();                }

                        public  SecurityUserResultData FindBySearchCriteria(SecurityUserSearchCriteria criteria)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<SecurityUserSearchCriteria,SecurityUserResultData>("/SecurityUser/FindBySearchCriteria" , criteria)).GetAwaiter().GetResult();                }

                        public  dynamic PrintBySearchCriteria(SecurityUserSearchCriteria criteria)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<SecurityUserSearchCriteria,dynamic>("/SecurityUser/PrintBySearchCriteria" , criteria)).GetAwaiter().GetResult();                }

                        public  SecurityUserData Insert(SecurityUserData data)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<SecurityUserData,SecurityUserData>("/SecurityUser/Insert" , data)).GetAwaiter().GetResult();                }

                        public  SecurityUserData Update(SecurityUserData data)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<SecurityUserData,SecurityUserData>("/SecurityUser/Update" , data)).GetAwaiter().GetResult();                }

                        public void Delete(string key)       
                {
 Task.Run(() =>   serviceRequest.PostAsync("/SecurityUser/Delete?key=" + key.ToString())).GetAwaiter().GetResult();                }

                        public void Deletes(string[] keys)       
                {
 Task.Run(() =>   serviceRequest.PostAsJsonAsync<string[],dynamic>("/SecurityUser/Deletes" , keys)).GetAwaiter().GetResult();                }

                        public   SecurityFunctionResultData FindMenuByUsername()
                {
return  Task.Run(() =>  serviceRequest.PostAsJsonAsync<SecurityFunctionResultData> ("/SecurityUser/FindMenuByUsername")).GetAwaiter().GetResult();                }

                        public void UpdateLocalName(string localName)       
                {
 Task.Run(() =>   serviceRequest.PostAsync("/SecurityUser/UpdateLocalName?localName=" + localName.ToString())).GetAwaiter().GetResult();                }

                
}
}