Example #1
0
        public bool Insert_Posting(int cate, int id)
        {
            bool result = false;

            try
            {
                mmoDataContext db   = new mmoDataContext();
                Posting        prod = new Posting
                {
                    Product_Id = cate,
                    Source_Id  = 1,
                    Site_id    = id
                };
                db.Postings.InsertOnSubmit(prod);
                db.SubmitChanges();
                result = true;
            }
            catch (Exception ex) { }
            return(result);
        }
Example #2
0
        public IEnumerable <DataLoad> GetProduct()
        {
            List <DataLoad> datas   = new List <DataLoad>();
            mmoDataContext  context = new mmoDataContext();
            var             query   = from prod in context.Products
                                      join catProd in context.ProductCategoryDetails on prod.Id equals catProd.Product_Id
                                      join cat in context.Categories on catProd.Category_Id equals cat.Id
                                      where !(from post in context.Postings select post.Product_Id).Contains(cat.Id) && prod.Sku != null
                                      select new { prod, cat };

            if (query != null)
            {
                foreach (var i in query)
                {
                    string   parent_category = (from a in context.Categories where a.Id == i.cat.Parent_Id select a).FirstOrDefault().Name;
                    DataLoad data            = new DataLoad();
                    data.Sku            = i.prod.Sku;
                    data.Title          = i.prod.Name;
                    data.Description    = i.prod.Description;
                    data.Image          = i.prod.Image;
                    data.Price          = decimal.Parse(i.prod.Price.ToString());
                    data.Keywords       = i.prod.Keywords;
                    data.GroupId        = i.prod.Group_Id;
                    data.Tag            = i.cat.Name;
                    data.Type           = Int32.Parse(i.prod.ProductTypeId.ToString());
                    data.TypeName       = i.prod.ProductType.Name;
                    data.Url            = i.prod.Url_Source;
                    data.UrlName        = i.prod.Url_Name.Split('/')[2];
                    data.Category       = parent_category;
                    data.CategorySearch = parent_category;
                    data.CateProdId     = i.cat.Id;
                    datas.Add(data);
                }
            }
            return(datas);
        }