コード例 #1
0
        public IHttpActionResult PostSchoolShift(SchoolShift schoolShift)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SchoolShifts.Add(schoolShift);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (SchoolShiftExists(schoolShift.SchoolShift1))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = schoolShift.SchoolShift1 }, schoolShift));
        }
コード例 #2
0
        public IHttpActionResult PutSchoolShift(string id, SchoolShift schoolShift)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != schoolShift.SchoolShift1)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SchoolShiftExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public IHttpActionResult GetSchoolShift(string id)
        {
            SchoolShift schoolShift = db.SchoolShifts.Find(id);

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

            return(Ok(schoolShift));
        }
コード例 #4
0
        public IHttpActionResult DeleteSchoolShift(string id)
        {
            SchoolShift schoolShift = db.SchoolShifts.Find(id);

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

            db.SchoolShifts.Remove(schoolShift);
            db.SaveChanges();

            return(Ok(schoolShift));
        }