コード例 #1
0
        public async Task <IHttpActionResult> PutDisabilityReason(int id, DisabilityReason disabilityReason)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != disabilityReason.ID)
            {
                return(BadRequest());
            }

            db.Entry(disabilityReason).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public async Task <IHttpActionResult> GetDisabilityReason(int id)
        {
            DisabilityReason disabilityReason = await db.DisabilityReasons.FindAsync(id);

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

            return(Ok(disabilityReason));
        }
コード例 #3
0
        public async Task <IHttpActionResult> PostDisabilityReason(DisabilityReason disabilityReason)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DisabilityReasons.Add(disabilityReason);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = disabilityReason.ID }, disabilityReason));
        }
コード例 #4
0
        public async Task <IHttpActionResult> DeleteDisabilityReason(int id)
        {
            DisabilityReason disabilityReason = await db.DisabilityReasons.FindAsync(id);

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

            db.DisabilityReasons.Remove(disabilityReason);
            await db.SaveChangesAsync();

            return(Ok(disabilityReason));
        }