コード例 #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();
     }
 }