private async void cargarListaPersonasDpto() { List <Department> listaDepartamentos; List <Person> listaPersonas; List <PersonDepartmentName> listaPersonasNombreDepartamento = new List <PersonDepartmentName>(); //Creamos un diccionario para almacenar la id de cada departamento asociada //con su nombre IDictionary <int, string> dict = new Dictionary <int, string>(); listaDepartamentos = await DepartmentHandlerBL.getDepartmentList(); foreach (Department item in listaDepartamentos) { dict[item.ID] = item.Name; } //Usando el objeto Persona traido de la api , junto con el diccionario //para realizar la asignación idDepartamento => nombreDepartamento, construimos //una lista de objetos PersonasNombreDepartamento listaPersonas = await PersonHandlerBL.getPersonListBL(); foreach (Person item in listaPersonas) { listaPersonasNombreDepartamento.Add(new PersonDepartmentName(item, dict[item.DepartmentID])); } //Asignamos a la variable de la clase la lista recien construida listaPersonasDpto = new ObservableCollection <PersonDepartmentName>(listaPersonasNombreDepartamento); }
public ActionResult Delete(PersonDepartmentName Person) { PersonHandlerBL handler = new PersonHandlerBL(); handler.deletePerson(Person.id); return(View("Done")); }
private async void ActualizarCommand_Execute() { await PersonHandlerBL.updatePersonBL(new Person(inputPerson.id, inputPerson.FirstName, inputPerson.LastName, inputPerson.PhoneNumber, inputPerson.Email, inputPerson.Birthdate, inputPerson.DepartmentID)); }
// PUT: api/Personas/5 public void Put([FromBody] Person personaActualizada) { try { PersonHandlerBL handler = new PersonHandlerBL(); handler.updatePerson(personaActualizada); } catch (Exception e) { //Conexión con las otras capas fallida throw new HttpResponseException(HttpStatusCode.ServiceUnavailable); } }
// DELETE: api/Personas/5 public void Delete(int id) { try { PersonHandlerBL handler = new PersonHandlerBL(); handler.deletePerson(id); } catch (Exception e) { //Conexión con las otras capas fallida throw new HttpResponseException(HttpStatusCode.ServiceUnavailable); } }
public ActionResult Edit(PersonDepartmentName Person) { PersonHandlerBL handler = new PersonHandlerBL(); //TODO: ONLY THE DEPARTMENT NAME SHOULD APPEAR IN THE VIEW. THERE SHOULD BE SOME LOGIC HERE BY WHICH //THE CHOSEN DEPARTMENT NAME IS TRANSLATED INTO ITS CORRESPONDING ID AS DepartmentListDAL's getDepartmentById //METHOD DOES WITH THE DEPARTMENT ID //The Person's id won't change, so we can use the updated Person's id for convenience handler.updatePerson(Person); return(View("Done")); }
private async void InsertarCommand_Execute() { //Leer TODO.txt el apartado NOTAS await PersonHandlerBL.insertPersonBL(new Person( inputPerson.id, inputPerson.FirstName, inputPerson.LastName, inputPerson.PhoneNumber, inputPerson.Email, inputPerson.Birthdate, inputPerson.DepartmentID));; }
public ActionResult Create(PersonDepartmentName Person) { PersonHandlerBL handler = new PersonHandlerBL(); Person newPerson = new Person(); newPerson.id = Person.id; newPerson.FirstName = Person.FirstName; newPerson.LastName = Person.LastName; newPerson.Birthdate = Person.Birthdate; newPerson.PhoneNumber = Person.PhoneNumber; newPerson.DepartmentID = Person.DepartmentID; handler.insertPerson(newPerson); return(View("Done")); }
private async void EliminarCommand_ExecuteAsync() { await PersonHandlerBL.deletePerson(personaSeleccionada.id); }