예제 #1
0
 private static Product GetProductByName(string name)
 {
     try
     {
         using (var context = new OleDbDataContext())
         {
             return context.Products.FirstOrDefault(p => p.ProductName == name && p.IsLastVersion == true);
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #2
0
        private static void AddProduct(Product product, Dictionary<string, List<string>> productDetails)
        {
            try
            {
                using (var context = new OleDbDataContext())
                {
                    context.Products.InsertOnSubmit(product);
                    context.SubmitChanges();

                    var p = GetProductByName(product.ProductName);

                    foreach (var key in productDetails.Keys)
                    {
                        // Jeżeli brak pojemności dla produktu nie tworzy wpisu
                        if (String.IsNullOrEmpty(key))
                        {
                            break;
                        }

                        foreach (var lang in productDetails[key])
                        {
                            // Jeżeli brak langów dla pojemności nie tworzy wpisu
                            if (String.IsNullOrEmpty(lang))
                            {
                                break;
                            }

                            var lv = new Language()
                            {
                                Lang = lang,
                                Volume = key,
                                ProductId = p.Id
                            };

                            context.Languages.InsertOnSubmit(lv);
                            context.SubmitChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #3
0
 private static List<Language> GetProductDetails(int id)
 {
     try
     {
         using (var context = new OleDbDataContext())
         {
             return context.Languages.Where(l => l.ProductId == id).ToList();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #4
0
        private static void UpdateProduct(Product product, Dictionary<string, List<string>> productDetails)
        {
            try
            {
                using (var context = new OleDbDataContext())
                {

                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }