예제 #1
0
        public async Task <IActionResult> PostLineRollingGuide([FromBody] LineRollingGuide lineRollingGuide)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.LineRollingGuides.Add(lineRollingGuide);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (LineRollingGuideExists(lineRollingGuide.TypeID))
                {
                    return(StatusCode((int)HttpStatusCode.Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = lineRollingGuide.TypeID }, lineRollingGuide));
        }
예제 #2
0
        public async Task <IActionResult> PutLineRollingGuide(string id, [FromBody] LineRollingGuide lineRollingGuide)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != lineRollingGuide.TypeID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode((int)HttpStatusCode.NoContent));
        }
예제 #3
0
        public async Task <IActionResult> GetLineRollingGuide(string id)
        {
            LineRollingGuide lineRollingGuide = await db.LineRollingGuides.FindAsync(id);

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

            return(Ok(lineRollingGuide));
        }
예제 #4
0
        public async Task <IActionResult> DeleteLineRollingGuide(string id)
        {
            LineRollingGuide lineRollingGuide = await db.LineRollingGuides.FindAsync(id);

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

            db.LineRollingGuides.Remove(lineRollingGuide);
            await db.SaveChangesAsync();

            return(Ok(lineRollingGuide));
        }