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)); }
public void Post(ADetail aDetail) { /* if (!ModelState.IsValid) * { * return BadRequest(ModelState); * }*/ db.Dbdetail.Add(aDetail); db.SaveChanges(); }
public IHttpActionResult GetADetail(int id) { ADetail aDetail = db.Dbdetail.Find(id); if (aDetail == null) { return(NotFound()); } return(Ok(aDetail)); }
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)); }
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)); }
public void Delete(int id) { ADetail spec = db.Dbdetail.Find(id); if (spec != null) { try { db.Dbdetail.Remove(spec); db.SaveChanges(); } catch (Exception) { throw; } } }
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)); }