Beispiel #1
0
        public async Task <IActionResult> PostFotoPropiedad([FromBody] FotoPropiedad fotoPropiedad)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.FotoPropiedad.Add(fotoPropiedad);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (FotoPropiedadExists(fotoPropiedad.NumeroPlanoPropiedad))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetFotoPropiedad", new { id = fotoPropiedad.NumeroPlanoPropiedad }, fotoPropiedad));
        }
Beispiel #2
0
        public async Task <IActionResult> PutFotoPropiedad([FromRoute] decimal id, [FromBody] FotoPropiedad fotoPropiedad)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != fotoPropiedad.NumeroPlanoPropiedad)
            {
                return(BadRequest());
            }

            _context.Entry(fotoPropiedad).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FotoPropiedadExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }