예제 #1
0
 public static Currency Find(int id)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Currencies.Find(id);
     }
 }
예제 #2
0
 public User Find(string Name)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Users.First(x => x.Login == Name);
     }
 }
예제 #3
0
 public List<Category> Select()
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Categories.ToList();
     }
 }
예제 #4
0
 public List<User> Select()
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Users.ToList();
     }
 }
예제 #5
0
 public static double Rate(int id)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Currencies.Find(id).Rate;
     }
 }
예제 #6
0
 public User Find(int id)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Users.Find(id);
     }
 }
예제 #7
0
 public static Adress FirstOrDefault(int userId)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Adresses.FirstOrDefault(s => s.UserId == userId);
     }
 }
예제 #8
0
 public static Picture Find(int productId)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Pictures.FirstOrDefault(s => s.ProductId == productId);
     }
 }
예제 #9
0
 public static List<Picture> Select(int productId)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Pictures.Where(s => s.ProductId == productId).ToList();
     }
 }
예제 #10
0
 public static List<Adress> Select(int userId)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Adresses.Where(s => s.UserId == userId).ToList();
     }
 }
예제 #11
0
 public static List<Currency> Select()
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Currencies.ToList();
     }
 }
예제 #12
0
 public Product Find(int id)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Products.Find(id);
     }
 }
예제 #13
0
        public static void Add(int productId, string name, string value)
        {
            using (var dbContext = new DataContext())
            {
                int nameId = 0;
                int valueId = 0;
                var paramName = dbContext.ParamNames.FirstOrDefault(s => s.Name.Equals(name));
                var paramValue = dbContext.ParamValues.FirstOrDefault(s => s.Name.Equals(value));
                if (paramName == null)
                {
                    paramName = dbContext.ParamNames.Add(new ParamName() { Name = name });
                    dbContext.SaveChanges();
                }
                nameId = paramName.ParamNameId;

                if (paramValue == null)
                {
                    paramValue = dbContext.ParamValues.Add(new ParamValue() { Name = value });
                    dbContext.SaveChanges();
                }
                valueId = paramValue.ParamValueId;

                dbContext.Parameters.Add(new Parameter()
                {
                    ParamValueId = valueId,
                    ParamNameId = nameId,
                    ProductId = productId
                });
                dbContext.SaveChanges();
            }
        }
예제 #14
0
        public static List<Tag> GetTagsFromString(String StringOfTags)
        {
            using (var dbContext = new DataContext())
            {
                String[] StrTags = StringOfTags.ToLower().Split(new Char[] { ',' });
                List<Tag> list = new List<Tag>();

                foreach (var tag in StrTags)
                {
                    var tags = dbContext.Tags.Where(s => s.Name == tag);
                    if (tags.Count() == 0)
                    {
                        dbContext.Tags.Add(new Tag { Name = tag, Value = 1 });
                        dbContext.SaveChanges();
                    }
                    else
                    {
                        tags.ToList()[0].Value++;
                        dbContext.SaveChanges();
                    }
                    list.Add(dbContext.Tags.FirstOrDefault(s => s.Name == tag));
                }
                return list;
            }
        }
예제 #15
0
 public static Store Find(int productId)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Store.Find(productId);
     }
 }
예제 #16
0
 public static Vendor Find(int id)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Vendors.Find(id);
     }
 }
예제 #17
0
 public List<Product> Select()
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Products.ToList();
     }
 }
예제 #18
0
 public static Adress Find(int id)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Adresses.Find(id);
     }
 }
예제 #19
0
 public Category Find(int id)
 {
     using (var dbContext = new DataContext())
     {
         return dbContext.Categories.Find(id);
     }
 }
예제 #20
0
 public static void Edit(Adress adress)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Entry(adress).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
예제 #21
0
 public static void Add(Adress adress)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Adresses.Add(adress);
         dbContext.SaveChanges();
     }
 }
예제 #22
0
 public static int ReturnId(int productId)
 {
     using (var dbContext = new DataContext())
     {
         Currency curr = dbContext.Products.Find(productId).Currency;
         return curr.CurrencyId;
     }
 }
예제 #23
0
 public List<Order> Select(int userId)
 {
     using (var dbContext = new DataContext())
     {
         var orders = Select();
         return orders = orders.Where(s => s.UserId == userId).ToList();
     }
 }
예제 #24
0
 public void Edit(Product product)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Entry(product).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
예제 #25
0
 public static List<Adress> Select(string userName)
 {
     using (var dbContext = new DataContext())
     {
         User user = new UserRepository().Find(userName);
         return dbContext.Adresses.Where(s => s.UserId == user.UserId).ToList();
     }
 }
예제 #26
0
 public List<Order> Select(DateTime searchString)
 {
     using (var dbContext = new DataContext())
     {
         var orders = Select();
         return orders = orders.Where(s => s.OrderData.CompareTo(searchString) >= 0).ToList();
     }
 }
예제 #27
0
 public void Add(Category category)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Categories.Add(category);
         dbContext.SaveChanges();
     }
 }
예제 #28
0
 public void Edit(Category category)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Entry(category).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
예제 #29
0
 public List<User> Select(String searchString)
 {
     using (var dbContext = new DataContext())
     {
         var users = Select();
         return users = users.Where(s => s.Login.Contains(searchString)).ToList();
     }
 }
예제 #30
0
 public static void Add(Basket basket)
 {
     using (var dbContext = new DataContext())
     {
         dbContext.Baskets.Add(basket);
         dbContext.SaveChanges();
     }
 }