コード例 #1
0
        public IHttpActionResult PutADetail(int id, ADetail aDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != aDetail.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public void Post(ADetail aDetail)
        {
            /* if (!ModelState.IsValid)
             * {
             *   return BadRequest(ModelState);
             * }*/

            db.Dbdetail.Add(aDetail);
            db.SaveChanges();
        }
コード例 #3
0
        public IHttpActionResult GetADetail(int id)
        {
            ADetail aDetail = db.Dbdetail.Find(id);

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

            return(Ok(aDetail));
        }
コード例 #4
0
        public IHttpActionResult PostADetail(ADetail aDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Dbdetail.Add(aDetail);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = aDetail.Id }, aDetail));
        }
コード例 #5
0
        public IHttpActionResult DeleteADetail(int id)
        {
            ADetail aDetail = db.Dbdetail.Find(id);

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

            db.Dbdetail.Remove(aDetail);
            db.SaveChanges();

            return(Ok(aDetail));
        }
コード例 #6
0
        public void Delete(int id)
        {
            ADetail spec = db.Dbdetail.Find(id);

            if (spec != null)
            {
                try
                {
                    db.Dbdetail.Remove(spec);
                    db.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
コード例 #7
0
        public IHttpActionResult GetId(int id)
        {
/*            List<ViewData> usr = new List<ViewData>();
 *
 *          var q = (from pd in db.Dbdetail
 *                   join od in db.Dbspecl on pd.Id equals od.DID where pd.Id==id
 *                   select new
 *                   {
 *                       pd.Id,
 *                       pd.Name,
 *                       pd.Phone,
 *                       pd.Address,
 *                       od.Spec,
 *                       od.SrNo
 *                   });
 *
 *          //     var module = new List<ViewModule>();
 *          foreach (var t in q)
 *          {
 *              usr.Add(new ViewData()
 *              {
 *                  Id = t.Id,
 *                  Name = t.Name,
 *                  Phone = t.Phone,
 *                  Address = t.Address,
 *                  Spec = t.Spec,
 *                  SrNo = t.SrNo
 *
 *              });
 *          }
 *
 *         return usr;*/


            ADetail aDetail = db.Dbdetail.Find(id);

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

            return(Ok(aDetail));
        }