// PUT api/Market/5 public HttpResponseMessage PutMarketPlace(int id, MarketPlace marketplace) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != marketplace.InvId) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(marketplace).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public T Insert(T entity) { if (entity == null) { throw new ArgumentNullException("Null entity"); } _table.Add(entity); _context.SaveChanges(); return(entity); }
public bool InserirUsuario(UsuarioTable usuario) { try { _context.Usuario.Add(usuario); _context.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public void CreateTestData(DbContextOptions <MarketPlaceContext> options) { using (var appcontext = new MarketPlaceContext(options)) { var ApplicationsToAdd = new List <Application> { new Application() { Id = 1, Name = "Github", Info = "Github Integration", AppUrl = "www.github.com", Developer = "Mr. XYZ", LogoUrl = "www.logo.com" }, new Application() { Id = 2, Name = "Google Drive", Info = "Google Drive Integration", AppUrl = "www.googledrive.com", Developer = "Mr. ABC", LogoUrl = "www.glogo.com" } }; appcontext.Application.AddRange(ApplicationsToAdd); appcontext.SaveChanges(); } }
public void AddCategory(SubCategory subCategory) { context.SubCategories.Add(subCategory); context.SaveChanges(); }
private void Save() { context.SaveChanges(); }