public async Task <IActionResult> PutPlace(long id, Place place)
        {
            if (id != place.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> UpdatePlace(long id, PlaceDTO placeDTO)
        {
            if (id != placeDTO.Id)
            {
                return(BadRequest());
            }
            var place = await _context.Places.FindAsync(id);

            if (place == null)
            {
                return(NotFound());
            }
            place.Name   = placeDTO.Name;
            place.IsOpen = placeDTO.IsOpen;
            place.Tags   = placeDTO.Tags;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!PlaceExists(id))
            {
                return(NotFound());
            }

            return(NoContent());
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("Id,Nom_PLA,Vat_PLA,EmailPro_PLA,FreeText_PLA,Logo_PLA,AddrPostalC_PLA,AddrCity_PLA,AddrCountry_PLA,AddrStreet_PLA,AddrPostBox_PLA,Phone_PLA,EmailPlace_PLA,Site_PLA,Instagram_PLA,Facebook_PLA,Linkedin_PLA,Hours_PLA,Picture_PLA")] Place place)
        {
            if (ModelState.IsValid)
            {
                _context.Add(place);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(place));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,IsComplete")] Place place)
        {
            if (ModelState.IsValid)
            {
                _context.Add(place);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(place));
        }
        public async Task <IActionResult> Create([Bind("Id,Stand,Shelf,Number,BookId")] Place place)
        {
            if (ModelState.IsValid)
            {
                _context.Add(place);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Title", place.BookId);
            return(View(place));
        }