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

        public void UpdateUser(User UserUP)
        {
            using (GarmentsContext context = new GarmentsContext())
            {
                context.Entry(UserUP).State = EntityState.Modified;
                context.SaveChanges();
            }
        }
예제 #5
0
 public List <Department> GetDepartments()
 {
     using (GarmentsContext contex = new GarmentsContext())
     {
         return((from d in contex.Departments
                 select d).ToList());
     }
 }
예제 #6
0
 public void AddDepartment(Department dept)
 {
     using (GarmentsContext contex = new GarmentsContext())
     {
         contex.Departments.Add(dept);
         contex.SaveChanges();
     }
 }
예제 #7
0
 public List <Category> GetCategories()
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         return((from c in context.Categories
                 .Include(c => c.Department)
                 select c).ToList());
     }
 }
예제 #8
0
 public void DeleteCategory(int id)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         Category found = context.Categories.Find(id);
         context.Categories.Remove(found);
         context.SaveChanges();
     }
 }
예제 #9
0
        // 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());
            }
        }
예제 #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();
     }
 }
예제 #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());
     }
 }
예제 #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());
     }
 }
예제 #13
0
        public List <Role> GetRoles()
        {
            GarmentsContext context = new GarmentsContext();

            using (context)
            {
                return((from u in context.Roles
                        select u).ToList());
            }
        }
예제 #14
0
 //Add new User
 public void AddUser(User user)
 {
     using (GarmentsContext context = new GarmentsContext())
     {
         if (user != null)
         {
             context.Users.Add(user);
             context.SaveChanges();
         }
     }
 }
예제 #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();
     }
 }
예제 #16
0
 //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());
     }
 }
예제 #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);
     }
 }
예제 #18
0
        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());
            }
        }
예제 #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());
            }
        }
예제 #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());
     }
 }
예제 #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();
     }
 }
예제 #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();
            }
        }
예제 #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();
     }
 }