예제 #1
0
        public IHttpActionResult PutANUNCIO(int id, ANUNCIO aNUNCIO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != aNUNCIO.ID)
            {
                return(BadRequest());
            }

            db.Entry(aNUNCIO).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ANUNCIOExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public void RegistroAnunciosLaborDom(int duracion,
                                             string horario,
                                             string nacionalidad,
                                             bool carnet,
                                             double sueldo,
                                             string zona,
                                             bool fumador,
                                             string tarea)
        {
            //Creamos una instancia de anuncio LABORES DOMESTICAS
            ANUNCIO   anuncio  = new ANUNCIO();
            LABOR_DOM laborDom = new LABOR_DOM();

            //Rellenamos el anuncio creado
            anuncio.Duracion     = duracion;
            anuncio.Horario      = horario;
            anuncio.Nacionalidad = nacionalidad;
            anuncio.Carnet       = carnet;
            anuncio.Sueldo       = sueldo;
            anuncio.Zona         = zona;
            anuncio.Fumador      = fumador;
            laborDom.Tarea       = tarea;
            anuncio.LABOR_DOM.Add(laborDom);
            //Añadimos a la base de datos el objeto anuncio
            database.ANUNCIO.Add(anuncio);
            //Guardamos los cambios
            try
            {
                database.SaveChanges();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
예제 #3
0
        public IHttpActionResult GetANUNCIO(int id)
        {
            ANUNCIO aNUNCIO = db.ANUNCIO.Find(id);

            if (aNUNCIO == null)
            {
                return(NotFound());
            }

            return(Ok(aNUNCIO));
        }
예제 #4
0
        public IHttpActionResult PostANUNCIO(ANUNCIO aNUNCIO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ANUNCIO.Add(aNUNCIO);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = aNUNCIO.ID }, aNUNCIO));
        }
예제 #5
0
        public IHttpActionResult DeleteANUNCIO(int id)
        {
            ANUNCIO aNUNCIO = db.ANUNCIO.Find(id);

            if (aNUNCIO == null)
            {
                return(NotFound());
            }

            db.ANUNCIO.Remove(aNUNCIO);
            db.SaveChanges();

            return(Ok(aNUNCIO));
        }
예제 #6
0
        //--------------------------------------------Registro de anuncios-------------------------------------------------------
        public void RegistroAnunciosClasePart(int duracion,
                                              string horario,
                                              string nacionalidad,
                                              bool carnet,
                                              double sueldo,
                                              string zona,
                                              bool fumador,
                                              string asignatura,
                                              string curso,
                                              string tipo,
                                              string lugar)
        {
            //Creamos una instancia de anuncio
            ANUNCIO    anuncio   = new ANUNCIO();
            CLASE_PART clasePart = new CLASE_PART();

            //Rellenamos el anuncio creado
            anuncio.Duracion     = duracion;
            anuncio.Horario      = horario;
            anuncio.Nacionalidad = nacionalidad;
            anuncio.Carnet       = carnet;
            anuncio.Sueldo       = sueldo;
            anuncio.Zona         = zona;
            anuncio.Fumador      = fumador;
            clasePart.Asignatura = asignatura;
            clasePart.Curso      = curso;
            clasePart.Tipo       = tipo;
            clasePart.Lugar      = lugar;
            anuncio.CLASE_PART.Add(clasePart);
            //Añadimos a la base de datos el objeto anuncio
            database.ANUNCIO.Add(anuncio);
            //Guardamos los cambios
            try
            {
                database.SaveChanges();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
예제 #7
0
        //--------------------------------------
        public void RegistroAnunciosCudadoPers(int duracion,
                                               string horario,
                                               string nacionalidad,
                                               bool carnet,
                                               double sueldo,
                                               string zona,
                                               bool fumador,
                                               short edad,
                                               short numero,
                                               string tipo)
        {
            //Creamos una instancia de anuncio CUIDADO DE PERSONAS
            ANUNCIO      anuncio     = new ANUNCIO();
            CUIDADO_PERS cuidadoPers = new CUIDADO_PERS();

            //Rellenamos el anuncio creado
            anuncio.Duracion     = duracion;
            anuncio.Horario      = horario;
            anuncio.Nacionalidad = nacionalidad;
            anuncio.Carnet       = carnet;
            anuncio.Sueldo       = sueldo;
            anuncio.Zona         = zona;
            anuncio.Fumador      = fumador;
            cuidadoPers.Edad     = edad;
            cuidadoPers.Numero   = numero;
            cuidadoPers.Tipo     = tipo;
            anuncio.CUIDADO_PERS.Add(cuidadoPers);
            //Añadimos a la base de datos el objeto anuncio
            database.ANUNCIO.Add(anuncio);
            //Guardamos los cambios
            try
            {
                database.SaveChanges();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }