public async Task <ActionResult <CampaignSetting> > PostCampaignSetting(CampaignSettingDTO CampaignSettingDTO) { var CampaignSetting = new CampaignSetting { Name = CampaignSettingDTO.Name, WorldId = CampaignSettingDTO.WorldId }; _context.CampaignSetting.Add(CampaignSetting); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetCampaignSetting), new { id = CampaignSetting.Id }, ItemToDTO(CampaignSetting))); }
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()); }
public void UpdateWithDTO(CampaignSettingDTO campaignSettingDto) { WorldId = campaignSettingDto.WorldId; Name = campaignSettingDto.Name; }