public async Task <IActionResult> PutSite(long id, Site site)
        {
            if (id != site.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutReservationModel(long id, ReservationModel reservationModel)
        {
            if (id != reservationModel.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <ActionResult <Image> > DeleteImage(long id)
        {
            var image = await _context.Image.FindAsync(id);

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

            _context.Image.Remove(image);
            await _context.SaveChangesAsync();

            //delete file
            var filePath = Path.Combine(_hostingEnvironment.ContentRootPath, image.Name);

            var fileInfo = new System.IO.FileInfo(filePath);

            fileInfo.Delete();


            return(image);
        }