コード例 #1
0
        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));
        }
コード例 #2
0
        public IHttpActionResult GetCampaignFinance(int id)
        {
            CampaignFinance campaignFinance = db.CampaignFinances.Find(id);

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

            return(Ok(campaignFinance));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }