public void Update(T item) { using (OMDBEntities context = new OMDBEntities()) { context.Set <T>().AddOrUpdate(item); context.SaveChanges(); } }
public void RemoveRange(Expression <Func <T, bool> > predicate) { using (OMDBEntities context = new OMDBEntities()) { context.Set <T>().RemoveRange(context.Set <T>().Where(predicate)); context.SaveChanges(); } }
public void Add(List <T> items) { using (OMDBEntities context = new OMDBEntities()) { context.Set <T>().AddRange(items); context.SaveChanges(); } }
public void Remove(int id) { using (OMDBEntities context = new OMDBEntities()) { T item = context.Set <T>().Find(id); if (item != null) { context.Set <T>().Remove(item); context.SaveChanges(); } } }
public void Add(T item) { using (OMDBEntities context = new OMDBEntities()) { try { context.Set <T>().Add(item); context.SaveChanges(); } catch (Exception e) { throw e; } } }
// POST: api/Product public HttpResponseMessage Post([FromBody] Product value) { try { if (ModelState.IsValid) { using (OMDBEntities Productdetails = new OMDBEntities()) { Productdetails.Products.Add(value); Productdetails.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Invalid Model")); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }