public static Currency Find(int id) { using (var dbContext = new DataContext()) { return dbContext.Currencies.Find(id); } }
public User Find(string Name) { using (var dbContext = new DataContext()) { return dbContext.Users.First(x => x.Login == Name); } }
public List<Category> Select() { using (var dbContext = new DataContext()) { return dbContext.Categories.ToList(); } }
public List<User> Select() { using (var dbContext = new DataContext()) { return dbContext.Users.ToList(); } }
public static double Rate(int id) { using (var dbContext = new DataContext()) { return dbContext.Currencies.Find(id).Rate; } }
public User Find(int id) { using (var dbContext = new DataContext()) { return dbContext.Users.Find(id); } }
public static Adress FirstOrDefault(int userId) { using (var dbContext = new DataContext()) { return dbContext.Adresses.FirstOrDefault(s => s.UserId == userId); } }
public static Picture Find(int productId) { using (var dbContext = new DataContext()) { return dbContext.Pictures.FirstOrDefault(s => s.ProductId == productId); } }
public static List<Picture> Select(int productId) { using (var dbContext = new DataContext()) { return dbContext.Pictures.Where(s => s.ProductId == productId).ToList(); } }
public static List<Adress> Select(int userId) { using (var dbContext = new DataContext()) { return dbContext.Adresses.Where(s => s.UserId == userId).ToList(); } }
public static List<Currency> Select() { using (var dbContext = new DataContext()) { return dbContext.Currencies.ToList(); } }
public Product Find(int id) { using (var dbContext = new DataContext()) { return dbContext.Products.Find(id); } }
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(); } }
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; } }
public static Store Find(int productId) { using (var dbContext = new DataContext()) { return dbContext.Store.Find(productId); } }
public static Vendor Find(int id) { using (var dbContext = new DataContext()) { return dbContext.Vendors.Find(id); } }
public List<Product> Select() { using (var dbContext = new DataContext()) { return dbContext.Products.ToList(); } }
public static Adress Find(int id) { using (var dbContext = new DataContext()) { return dbContext.Adresses.Find(id); } }
public Category Find(int id) { using (var dbContext = new DataContext()) { return dbContext.Categories.Find(id); } }
public static void Edit(Adress adress) { using (var dbContext = new DataContext()) { dbContext.Entry(adress).State = EntityState.Modified; dbContext.SaveChanges(); } }
public static void Add(Adress adress) { using (var dbContext = new DataContext()) { dbContext.Adresses.Add(adress); dbContext.SaveChanges(); } }
public static int ReturnId(int productId) { using (var dbContext = new DataContext()) { Currency curr = dbContext.Products.Find(productId).Currency; return curr.CurrencyId; } }
public List<Order> Select(int userId) { using (var dbContext = new DataContext()) { var orders = Select(); return orders = orders.Where(s => s.UserId == userId).ToList(); } }
public void Edit(Product product) { using (var dbContext = new DataContext()) { dbContext.Entry(product).State = EntityState.Modified; dbContext.SaveChanges(); } }
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(); } }
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(); } }
public void Add(Category category) { using (var dbContext = new DataContext()) { dbContext.Categories.Add(category); dbContext.SaveChanges(); } }
public void Edit(Category category) { using (var dbContext = new DataContext()) { dbContext.Entry(category).State = EntityState.Modified; dbContext.SaveChanges(); } }
public List<User> Select(String searchString) { using (var dbContext = new DataContext()) { var users = Select(); return users = users.Where(s => s.Login.Contains(searchString)).ToList(); } }
public static void Add(Basket basket) { using (var dbContext = new DataContext()) { dbContext.Baskets.Add(basket); dbContext.SaveChanges(); } }