Exemple #1
0
 public List <Color> GetColors()
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         return((from c in context.Colors select c).ToList());
     }
 }
Exemple #2
0
 public List <Fabric> GetFabrics()
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         return((from f in context.Fabrics select f).ToList());
     }
 }
Exemple #3
0
 public List <Size> GetSizes()
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         return((from s in context.Sizes select s).ToList());
     }
 }
        //Update User

        public void UpdateUser(User UserUP)
        {
            using (GarmentsContext context = new GarmentsContext())
            {
                context.Entry(UserUP).State = EntityState.Modified;
                context.SaveChanges();
            }
        }
Exemple #5
0
 public List <Department> GetDepartments()
 {
     using (GarmentsContext contex = new GarmentsContext())
     {
         return((from d in contex.Departments
                 select d).ToList());
     }
 }
Exemple #6
0
 public void AddDepartment(Department dept)
 {
     using (GarmentsContext contex = new GarmentsContext())
     {
         contex.Departments.Add(dept);
         contex.SaveChanges();
     }
 }
Exemple #7
0
 public List <Category> GetCategories()
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         return((from c in context.Categories
                 .Include(c => c.Department)
                 select c).ToList());
     }
 }
Exemple #8
0
 public void DeleteCategory(int id)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         Category found = context.Categories.Find(id);
         context.Categories.Remove(found);
         context.SaveChanges();
     }
 }
        // Get Email exist

        public User GetEmailExist(Object value)
        {
            using (GarmentsContext context = new GarmentsContext())
            {
                return((from c in context.Users
                        where c.Email.Equals(value.ToString(), StringComparison.CurrentCultureIgnoreCase)
                        select c).FirstOrDefault());
            }
        }
Exemple #10
0
 public void AddCategory(Category category)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         context.Entry(category.Department).State = EntityState.Unchanged;
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Exemple #11
0
 //#region departments
 public Department GetDepartment(int id)
 {
     using (GarmentsContext contex = new GarmentsContext())
     {
         return((from d in contex.Departments
                 where d.Id == id
                 select d).First());
     }
 }
Exemple #12
0
 public List <SubCategory> GetSubCategories(Category category)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         return((from c in context.SubCategories
                 .Include(c => c.Category.Department)
                 where c.Category.Id == category.Id
                 select c).ToList());
     }
 }
        public List <Role> GetRoles()
        {
            GarmentsContext context = new GarmentsContext();

            using (context)
            {
                return((from u in context.Roles
                        select u).ToList());
            }
        }
 //Add new User
 public void AddUser(User user)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         if (user != null)
         {
             context.Users.Add(user);
             context.SaveChanges();
         }
     }
 }
Exemple #15
0
 public void DeleteDepartment(int idToSearch)
 {
     using (GarmentsContext contex = new GarmentsContext())
     {
         Department found = (from d in contex.Departments
                             where d.Id == idToSearch
                             select d).First();
         contex.Departments.Remove(found);
         contex.SaveChanges();
     }
 }
 //User For Cookies
 public User GetUserForCookie(string loginid, string password)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         return((from u in context.Users
                 .Include("Role")
                 .Include("Address.City.Province.Country")
                 where u.LoginId.Equals(loginid) && u.Password.Equals(password)
                 select u).FirstOrDefault());
     }
 }
Exemple #17
0
 public Category GetCategory(int id)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         Category found = (from c in context.Categories
                           .Include(c => c.Department)
                           where c.Id == id
                           select c).FirstOrDefault();
         return(found);
     }
 }
        public List <User> GetUsers()
        {
            GarmentsContext context = new GarmentsContext();

            using (context)
            {
                return((from u in context.Users
                        .Include("Role")
                        .Include("Address.City.Province.Country")
                        select u).ToList());
            }
        }
Exemple #19
0
        //#endregion

        #region products
        public List <Product> GetProducts()
        {
            using (GarmentsContext context = new GarmentsContext())
            {
                return((from p in context.Products
                        .Include(p => p.Fabric)
                        .Include(p => p.Images)
                        .Include(p => p.ColorsOffered)
                        .Include(p => p.SizesOffered)
                        .Include(p => p.SubCategory.Category.Department)
                        select p).ToList());
            }
        }
Exemple #20
0
 public Product GetProduct(int id)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         return((from p in context.Products
                 .Include(p => p.Fabric)
                 .Include(p => p.Images)
                 .Include(p => p.ColorsOffered)
                 .Include(p => p.SizesOffered)
                 .Include(p => p.SubCategory.Category.Department)
                 where p.Id == id
                 select p).First());
     }
 }
Exemple #21
0
 public void UpdateDepartment(int idToSearch, Department dept)
 {
     using (GarmentsContext contex = new GarmentsContext())
     {
         Department found = (from d in contex.Departments
                             where d.Id == idToSearch
                             select d).First();
         if (!string.IsNullOrWhiteSpace(dept.Name))
         {
             found.Name = dept.Name;
         }
         found.ImageUrl = dept.ImageUrl;
         contex.SaveChanges();
     }
 }
Exemple #22
0
        public void AddProduct(Product product)
        {
            using (GarmentsContext context = new GarmentsContext())
            {
                context.Entry(product.Fabric).State      = EntityState.Unchanged;
                context.Entry(product.SubCategory).State = EntityState.Unchanged;
                foreach (var c in product.ColorsOffered)
                {
                    context.Entry(c).State = EntityState.Unchanged;
                }
                foreach (var s in product.SizesOffered)
                {
                    context.Entry(s).State = EntityState.Unchanged;
                }

                context.Products.Add(product);
                context.SaveChanges();
            }
        }
Exemple #23
0
 public void UpdateCategory(int id, Category category)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         Category found = context.Categories.Find(id);
         if (!string.IsNullOrWhiteSpace(category.Name))
         {
             found.Name = category.Name;
         }
         if (!string.IsNullOrWhiteSpace(category.ImageUrl))
         {
             found.ImageUrl = category.ImageUrl;
         }
         if (category.Department != null && category.Department.Id > 0)
         {
             found.Department = category.Department;
         }
         context.Entry(category.Department).State = EntityState.Unchanged;
         context.SaveChanges();
     }
 }