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

            if (id != appreciationReason.AppreciationReasonId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public async Task <IHttpActionResult> GetAppreciationReason(int id)
        {
            AppreciationReason appreciationReason = await db.AppreciationReasons.FindAsync(id);

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

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

            db.AppreciationReasons.Add(appreciationReason);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = appreciationReason.AppreciationReasonId }, appreciationReason));
        }
コード例 #4
0
        public async Task <IHttpActionResult> DeleteAppreciationReason(int id)
        {
            AppreciationReason appreciationReason = await db.AppreciationReasons.FindAsync(id);

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

            db.AppreciationReasons.Remove(appreciationReason);
            await db.SaveChangesAsync();

            return(Ok(appreciationReason));
        }