Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public void Post(ADetail aDetail)
        {
            /* if (!ModelState.IsValid)
             * {
             *   return BadRequest(ModelState);
             * }*/

            db.Dbdetail.Add(aDetail);
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetADetail(int id)
        {
            ADetail aDetail = db.Dbdetail.Find(id);

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

            return(Ok(aDetail));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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));
        }