//Add Employee
 public void Add(Employee item)
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         db.Employee.Add(item);
         db.SaveChanges();
     }
 }
Exemple #2
0
 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();
     }
 }
Exemple #4
0
 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();
     }
 }
Exemple #7
0
 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();
     }
 }
Exemple #11
0
 //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();
            }
        }
Exemple #13
0
        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);
            }
        }