コード例 #1
0
        public async Task <IActionResult> PutLiveTour(int id, LiveTour liveTour)
        {
            int idAgency = await _userService.GetAuthorizedAgencyId(this.User);

            if (id != liveTour.Id)
            {
                return(BadRequest());
            }

            if (liveTour.AgencyID != idAgency)
            {
                return(BadRequest(new { message = "resource is not yours" }));
            }

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

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PutBaseTour(int id, BaseTour baseTour)
        {
            int idAgency = await _userService.GetAuthorizedAgencyId(this.User);


            if (id != baseTour.Id)
            {
                return(BadRequest());
            }
            //var oldBaseTour = await _context.BaseTours.Where(b => b.AgencyID == idAgency && b.Id == id).FirstOrDefaultAsync();
            if (baseTour.AgencyID != idAgency)
            {
                return(BadRequest(new { message = "resource is not yours" }));
            }

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

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

            return(NoContent());
        }
コード例 #3
0
ファイル: UserController.cs プロジェクト: SmartTour/WebApi
        public async Task <IActionResult> PutUserData(User user)
        {
            int id = _userService.GetAuthorizedUserId(this.User);

            if (id != user.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #4
0
        public async Task <IActionResult> PutAgency(Agency agency)
        {
            int idAgency = await _userService.GetAuthorizedAgencyId(this.User);

            if (idAgency != agency.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) //forse non serve
            {
                if (!AgencyExists(idAgency))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }