示例#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();
     }
 }