Пример #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         this.Validate();
         this.rootProductsBindingSource.EndEdit();
         this.rootProductsTableAdapter.Update(this.dBIndi.RootProducts);
         foreach (var item in dBIndi.RootProducts)
         {
             if (item.IsActive)
             {
                 var rootProduct = new SolrRootProductItem
                 {
                     Id          = item.Id,
                     Name        = item.Name,
                     Image       = item.Image,
                     LocalPath   = item.LocalPath,
                     MinPrice    = item.MinPrice,
                     NumMerchant = item.NumMerchant,
                     WebsiteId   = item.WebsiteId,
                     CategoryId  = item.CategoryId
                 };
                 try
                 {
                     _solrRootProductClient.Insert(rootProduct);
                 }
                 catch (Exception exException)
                 {
                     Log.Error(exException);
                     //throw;
                 }
             }
             else
             {
                 try
                 {
                     _solrRootProductClient.Delete(item.Id);
                 }
                 catch (Exception exException)
                 {
                     Log.Error(exException);
                     //throw;
                 }
             }
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(@"Lưu lỗi r !! " + exception.Message);
     }
 }
Пример #2
0
        private void InsertSolrRootProduct(RootProductSql rootProductSql, SolrRootProductClient solrRootProductClient)
        {
            var item = new SolrRootProductItem
            {
                Id          = rootProductSql.RootId,
                Name        = rootProductSql.Name,
                Image       = rootProductSql.Image,
                LocalPath   = rootProductSql.LocalPath,
                MinPrice    = rootProductSql.MinPrice,
                NumMerchant = rootProductSql.NumMerchant,
                WebsiteId   = rootProductSql.WebsiteId,
                CategoryId  = rootProductSql.CategoryId
            };

            try
            {
                solrRootProductClient.Insert(item);
            }
            catch (Exception exException)
            {
                Log.Error(exException);
                //throw;
            }
        }