public IHttpActionResult PutCampaignFinance(int id, CampaignFinance campaignFinance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != campaignFinance.Id) { return(BadRequest()); } db.Entry(campaignFinance).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CampaignFinanceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCampaignFinance(int id) { CampaignFinance campaignFinance = db.CampaignFinances.Find(id); if (campaignFinance == null) { return(NotFound()); } return(Ok(campaignFinance)); }
public IHttpActionResult PostCampaignFinance(CampaignFinance campaignFinance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CampaignFinances.Add(campaignFinance); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = campaignFinance.Id }, campaignFinance)); }
public IHttpActionResult DeleteCampaignFinance(int id) { CampaignFinance campaignFinance = db.CampaignFinances.Find(id); if (campaignFinance == null) { return(NotFound()); } db.CampaignFinances.Remove(campaignFinance); db.SaveChanges(); return(Ok(campaignFinance)); }