/** * CreateAcountEmployee Method * It is used to create an employee with all parameters */ public static Employee createAccountEmployee(int activation, String lastname, String firstname, String pwd, String login, String address, String PC, String city, String phone, String hireDateDay, String hireDateMonth, String hireDateYear, int district, int employee_type_id) { JObject jsonParse = JObject.Parse(RAO.post("createAccountEmployee", "activation=" + activation + "&firstname=" + firstname + "&lastname=" + lastname + "&password="******"&login="******"&address=" + address + "&postalCode=" + PC + "&city=" + city + "&phone=" + phone + "&hireDate=" + hireDateYear + "/" + hireDateMonth + "/" + hireDateDay + "&district_id=" + district + "&employee_type_id=" + employee_type_id)); if (lastname.ToString().Length > 0) { return(JsonConvert.DeserializeObject <Employee>(jsonParse.ToString())); } else { return(null); } }
/* * GetAllEmployee Method * It is used to displat all acount in the datagridview */ public static List <Employee> getAllEmployee() { JArray jsonParse = JArray.Parse(RAO.get("allAccountsEmployees")); List <Employee> employees = new List <Employee>(); foreach (var employee in jsonParse) { Employee oneEmployee = JsonConvert.DeserializeObject <Employee>(employee.ToString()); employees.Add(oneEmployee); } return(employees); }
/* * ModifyEmployee Method * It is used to change datas about an employee */ public static Employee modifyEmployee(String login, String lastname, String firstname, String address, String city, String postalCode, String phone, int activation, int employee_type_id) { JObject jsonparse = JObject.Parse(RAO.put("modifyAccountEmployee", "login="******"&lastname=" + lastname + "&firstname=" + firstname + "&address=" + address + "&city=" + city + "&postalCode=" + postalCode + "&phone=" + phone + "&activation=" + activation + "&employee_type_id=" + employee_type_id)); if (lastname.ToString().Length > 0) { return(JsonConvert.DeserializeObject <Employee>(jsonparse.ToString())); } else { return(null); } }
/** * Auth method * Allow the connection */ public static Employee auth(String login, String password) { // Transforme la chaine de caractère du RAO en objet JSON = parser JObject jsonParse = JObject.Parse(RAO.post("auth", "login="******"&password="******"token"].ToString().Length > 0) { // Retourne un objet de la classe Login à partir de la chaine de caractère de l'objet JSON parsé avec clef "content" return(JsonConvert.DeserializeObject <Employee>(jsonParse.ToString())); } else { return(null); } }