示例#1
0
        public async Task <IActionResult> PutAttraction(int id, Attraction attraction)
        {
            if (id != attraction.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutGidHelper(int id, GidHelper gidHelper)
        {
            if (id != gidHelper.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#3
0
        public async Task <ActionResult <TourComment> > AddTourComment(int tourId, TourComment tourComment)
        {
            tourComment.TourId = tourId;
            _context.TourComments.Add(tourComment);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TourCommentExists(tourComment.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }