コード例 #1
0
        public async Task <IActionResult> PutResource(long id, Resource resource)
        {
            if (id != resource.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PutAsset(long id, Asset asset)
        {
            if (id != asset.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #3
0
        public async Task <IActionResult> PutCampaignSetting(CampaignSettingDTO CampaignSettingDTO)
        {
            var CampaignSetting = await _context.CampaignSetting.FindAsync(CampaignSettingDTO.Id);

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

            CampaignSetting.UpdateWithDTO(CampaignSettingDTO);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!CampaignSettingExists(CampaignSettingDTO.Id))
            {
                return(NotFound());
            }

            return(NoContent());
        }