public IHttpActionResult PutPaginacion(int id, Paginacion paginacion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != paginacion.PaginacionId) { return(BadRequest()); } db.Entry(paginacion).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PaginacionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutAspNetUserRoles(string id, AspNetUserRoles aspNetUserRoles) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != aspNetUserRoles.UserId) { return(BadRequest()); } db.Entry(aspNetUserRoles).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AspNetUserRolesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutCategoriasNoticias(int id, CategoriasNoticias categoriasNoticias) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != categoriasNoticias.CategoriaId) { return(BadRequest()); } db.Entry(categoriasNoticias).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CategoriasNoticiasExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutEstados(int id, Estados estados) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != estados.EstadoId) { return(BadRequest()); } db.Entry(estados).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EstadosExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IActionResult Create(Article article) { if (ModelState.IsValid) { article.UserName = User.Identity.Name; db.Articles.Add(article); db.SaveChanges(); return(RedirectToAction("ShowList")); } return(View()); }
public bool DeleteArticle(int id) { try { Article art = test.Articles.Where(s => s.ArticleId == id).First(); test.Articles.Remove(art); test.SaveChanges(); return(true); } catch (System.Exception) { return(false); } }
public void Add(User entity) { context.Users.Add(entity); context.SaveChanges(); }
public void Add(Comment entity) { context.Comments.Add(entity); context.SaveChanges(); }
public void Add(Article entity) { context.Articles.Add(entity); context.SaveChanges(); }
public void Add(Category entity) { context.Categorys.Add(entity); context.SaveChanges(); }
protected void Save() => _context.SaveChanges();