public ActualizacionEmpleado(PersonDepartmentName person)
        {
            InitializeComponent();
            VMActualizacionEmpleado VM = (VMActualizacionEmpleado)BindingContext;

            VM.InputPerson = person;
        }
示例#2
0
        //This parameter is going to be provided by the ActionLink's third parameter in Edit's view
        public ActionResult Edit(int id)
        {
            //This commented code is the code that should be used with model PersonDepartmentList, which is, in the first place
            //how this is supposed to be designed

            /* //Finding the person clicked
             * PersonListBL PersonList = new PersonListBL();
             * Person Person = PersonList.getPersonById(id);
             *
             * //Retrieving a list of departments
             * DepartmentListBL DepartmentList = new DepartmentListBL();
             * List<Department> list = DepartmentList.getDepartmentList();
             *
             * //Building our model with the clicked Person's data and the department list
             * PersonDepartmentList finalResult = new PersonDepartmentList(Person, list);*/

            //CODE USED WITH PersonDepartmentName MODEL
            //Finding the person clicked
            PersonListBL PersonList = new PersonListBL();
            Person       Person     = PersonList.getPersonById(id);

            DepartmentListBL list = new DepartmentListBL();
            //Building our model with the clicked Person's data. Person's field DepartmentID is translated into its corresponding department name
            PersonDepartmentName finalResult = new PersonDepartmentName(Person, list.getDepartmentById(Person.DepartmentID).Name);

            return(View(finalResult));
        }
示例#3
0
        public VMActualizacionEmpleado(PersonDepartmentName persona)
        {
            //Se ponen los valores por defecto en los inputs de la vista y se carga el listado de departamentos
            //del Picker

            InputPerson = persona;
            cargarListaDpto();
        }
示例#4
0
        public ActionResult Delete(PersonDepartmentName Person)
        {
            PersonHandlerBL handler = new PersonHandlerBL();

            handler.deletePerson(Person.id);

            return(View("Done"));
        }
示例#5
0
        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"));
        }
示例#6
0
        public ActionResult Details(int id)
        {
            //Finding the person clicked
            PersonListBL PersonList = new PersonListBL();
            Person       Person     = PersonList.getPersonById(id);

            DepartmentListBL DepartmentList = new DepartmentListBL();
            Department       department     = DepartmentList.getDepartmentById(Person.DepartmentID);

            PersonDepartmentName finalResult = new PersonDepartmentName(Person, department.Name);

            return(View(finalResult));
        }
示例#7
0
        public ActionResult Delete(int id)
        {
            //CODE USED WITH PersonDepartmentName MODEL
            //Finding the person clicked
            PersonListBL PersonList = new PersonListBL();
            Person       Person     = PersonList.getPersonById(id);

            DepartmentListBL list = new DepartmentListBL();
            //Building our model with the clicked Person's data. Person's field DepartmentID is translated into its corresponding department name
            PersonDepartmentName finalResult = new PersonDepartmentName(Person, list.getDepartmentById(Person.DepartmentID).Name);

            return(View(finalResult));
        }
示例#8
0
        // GET: api/PersonasDepartmentName/5
        public HttpResponseMessage Get(int id)
        {
            PersonDepartmentName oPersonaNombre = null;
            HttpResponseMessage  respuesta;

            try
            {
                PersonListBL     personListHandler     = new PersonListBL();
                DepartmentListBL departmentListHandler = new DepartmentListBL();

                //Obtenemos la persona solicitada sin el nombre de departamento
                //y la usamos para instanciar un objeto PersonDepartmentName,
                //junto con el nombre de departamento que le corresponde a la id de departamento

                Person oPersonaSinNombre = personListHandler.getPersonById(id);

                //Obtenemos la lista de personas sin el nombre de departamento
                //y en cada iteración del bucle, usamos cada una de las personas para
                //instanciar un nuevo objeto PersonDepartmentName y añadirlo a la lista
                //que vamos a devolver

                oPersonaNombre = new PersonDepartmentName(oPersonaSinNombre,
                                                          //Obteniendo el nombre de departamento a partir de la id
                                                          departmentListHandler.getDepartmentById(oPersonaSinNombre.DepartmentID).Name);
            }
            catch (HttpResponseException e)
            {
                //Conexión con las otras capas fallida
                throw new HttpResponseException(HttpStatusCode.ServiceUnavailable);
            }
            finally
            {
                if (oPersonaNombre == null)
                {
                    //Según el estándar http, NO se debe incluir contenido
                    //en las respuestas http de no content
                    respuesta = Request.CreateResponse(HttpStatusCode.NoContent);
                }
                else
                {
                    respuesta = Request.CreateResponse(HttpStatusCode.OK, oPersonaNombre);
                }
            }

            return(respuesta);
        }
示例#9
0
        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"));
        }
示例#10
0
 public ActualizacionEmpleado(PersonDepartmentName person)
 {
     InitializeComponent();
     VM = new VMActualizacionEmpleado(person);
 }