public bool LoginWithHashedPassword(string username, string hash) { var user = new User() { UserName = username, PasswordHash = hash }; var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false)); var json = JsonConvert.SerializeObject(user, Formatting.Indented); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var response = client.PostAsync("api/auth/login", httpContent).Result; if (response.IsSuccessStatusCode) { Auth.SessionToken = ExtractToken(response); StoreToVault(username, hash); Employee employee = EmployeeService.Instance.GetEmployeeByUserName(username); if (employee != null) { SessionContext.CurrentSubject = employee; } return(true); } return(false); }
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup <Startup>() .UseUrls(new string[] { AddressResolver.GetAddress("KlipperApi", true), AddressResolver.GetAddress("KlipperApi", false), }) ;
public async Task <Department> GetDepartmentByNameAsync(string departmentName) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("OperationalsApi", false)); var str = "api/departments/ByDepartmentName?departmentName=" + departmentName; HttpResponseMessage response = await client.GetAsync(str); var jsonString = await response.Content.ReadAsStringAsync(); var department = JsonConvert.DeserializeObject <Department>(jsonString); return(department); }
public async Task <IEnumerable <AccessEvent> > GetAttendanceByEmployeeIdAsync(int employeeId) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("AttendanceApi", false)); var str = "api/accessevents/byEmployeeId?employeeId=" + employeeId.ToString(); HttpResponseMessage response = await client.GetAsync(str); var jsonString = await response.Content.ReadAsStringAsync(); var accessEvents = JsonConvert.DeserializeObject <List <AccessEvent> >(jsonString); return(accessEvents); }
public async Task <Employee> GetEmployeeByIdAsync(int employeeId) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("EmployeeApi", false)); var str = "api/employees/" + employeeId.ToString(); HttpResponseMessage response = await client.GetAsync(str); var jsonString = await response.Content.ReadAsStringAsync(); var employee = JsonConvert.DeserializeObject <Employee>(jsonString); return(employee); }
public List <DateTime> GetHolidaysByYear(int year) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); var str = "api/worktime/holidays/" + year.ToString(); HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var holidays = JsonConvert.DeserializeObject <List <DateTime> >(jsonString); return(holidays); } else { return(null); } }
public Employee GetEmployeeById(int employeeId) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); var str = "api/employees/" + employeeId.ToString(); HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var employee = JsonConvert.DeserializeObject <Employee>(jsonString); return(employee); } else { return(null); } }
public Department GetDepartmentById(int departmentId) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); var str = "api/departments/" + departmentId.ToString(); HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var department = JsonConvert.DeserializeObject <Department>(jsonString); return(department); } else { return(null); } }
public Employee GetEmployeeByUserName(string userName) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); //KK: Please add this action on Employees controller in KlipperAPI var str = "api/employees/ByUserName?userName=" + userName; HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var employee = JsonConvert.DeserializeObject <Employee>(jsonString); return(employee); } else { return(null); } }
public Department GetDepartmentByName(string departmentName) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); //KK: Please add this action on Employees controller in KlipperAPI var str = "api/departments/ByName?departmentName=" + departmentName; HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var department = JsonConvert.DeserializeObject <Department>(jsonString); return(department); } else { return(null); } }
public IEnumerable <AccessEvent> GetAccessEvents(int employeeId, DateTime date) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); var startStr = date.Year.ToString() + "-" + date.Month.ToString() + "-" + date.Day.ToString(); var endStr = startStr; var str = "api/attendance/" + employeeId.ToString() + "/" + startStr + "/" + endStr; HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var accessEvents = JsonConvert.DeserializeObject <IEnumerable <AccessEvent> >(jsonString); return(accessEvents); } else { return(new List <AccessEvent>()); } }