//Add Employee public void Add(Employee item) { using (EMSDBContext db = new EMSDBContext()) { db.Employee.Add(item); db.SaveChanges(); } }
public void Update(Employee employee) { using (EMSDBContext db = new EMSDBContext()) { db.Employee.Update(employee); db.SaveChanges(); } }
public void UpdateCategory(Category category) { using (var context = new EMSDBContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public int SaveOrder(Order order) { using (var context = new EMSDBContext()) { context.Orders.Add(order); return(context.SaveChanges()); } }
public void UpdateProduct(Product product) { using (var context = new EMSDBContext()) { context.Entry(product).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void SaveCategory(Category category) { using (var context = new EMSDBContext()) { context.Categories.Add(category); context.SaveChanges(); } }
public void Update(Project item) { using (EMSDBContext db = new EMSDBContext()) { db.Project.Update(item); db.SaveChanges(); } }
//Delete Record public void Delete(string eid) { using (EMSDBContext db = new EMSDBContext()) { Employee e = db.Employee.Find(eid); db.Employee.Remove(e); db.SaveChanges(); } }
public void DeleteProduct(int ID) { using (var context = new EMSDBContext()) { var product = context.Products.Find(ID); context.Products.Remove(product); context.SaveChanges(); } }
public void SaveProduct(Product product) { using (var context = new EMSDBContext()) { context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged; context.Products.Add(product); context.SaveChanges(); } }
//Delete Project public void Delete(int id) { using (EMSDBContext db = new EMSDBContext()) { Project p = db.Project.Find(id); db.Project.Remove(p); db.SaveChanges(); } }
public void DeleteCategory(int ID) { using (var context = new EMSDBContext()) { var category = context.Categories.Where(x => x.ID == ID).Include(x => x.Products).FirstOrDefault(); context.Products.RemoveRange(category.Products); //first delete products of this category context.Categories.Remove(category); context.SaveChanges(); } }
public bool UpdateOrderStatus(int ID, string status) { using (var context = new EMSDBContext()) { var order = context.Orders.Find(ID); order.Status = status; context.Entry(order).State = EntityState.Modified; return(context.SaveChanges() > 0); } }