public async Task <IHttpActionResult> GetOneTAB_Views(int id) { TAB_Views v = await db.TAB_Views.FindAsync(id); if (v == null) { return(NotFound()); } var reponse = new ViewModel(); reponse.ID_View = v.ID_View; reponse.ID_User = v.ID_User.GetValueOrDefault(); reponse.ViewName = v.ViewName; reponse.ViewDesc = v.ViewDesc; reponse.CreationDate = v.CreationDate; return(Ok(reponse)); }
public async Task <IHttpActionResult> PutTAB_Views(int id, ViewModel view) { /* * if (id != view.ID_View) * { * return BadRequest(); * } */ TAB_Views v = await db.TAB_Views.FindAsync(id); if (v == null) { return(NotFound()); } v.ViewName = view.ViewName; v.ViewDesc = view.ViewDesc; db.Entry(v).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TAB_ViewsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> DeleteTAB_Views(int id) { TAB_Views tAB_Views = await db.TAB_Views.FindAsync(id); if (tAB_Views == null) { return(NotFound()); } db.TAB_Views.Remove(tAB_Views); ViewModel view = new ViewModel(); view.ID_View = tAB_Views.ID_View; view.ID_User = tAB_Views.ID_User.GetValueOrDefault(); view.ViewName = tAB_Views.ViewName; view.ViewDesc = tAB_Views.ViewDesc; await db.SaveChangesAsync(); return(Ok(view)); }