예제 #1
0
        /// <summary>
        /// 添加地址
        /// </summary>
        /// <param name="mod"></param>
        /// <returns></returns>
        public ShoppingAddress AddAddress(User_AddressDTO mod, string userId)
        {
            var             li   = EF.UserInfos.FirstOrDefault(a => a.UserID == userId);
            ShoppingAddress amod = new ShoppingAddress()
            {
                UserId   = mod.UserID,
                Name     = mod.Name,
                Phone    = mod.Phone,
                Address  = mod.Address,
                IsDelect = true
            };

            EF.ShoppingAddresses.Add(amod);
            if (EF.SaveChanges() > 0)
            {
                return(amod);
            }
            return(null);
        }
예제 #2
0
        /// <summary>
        /// 商品页
        /// </summary>
        /// <param name="goodid"></param>
        /// <returns></returns>
        public DetailsOutput GetGood(string goodid, string gsid)
        {
            var data = (from a in EF.Goods
                        join c in EF.GoodCategories on a.CategoryID equals c.CategoryID
                        join d in EF.Good_Specifications on a.GoodId equals d.GoodId
                        where a.GoodId == goodid && a.IsDelect == true && c.IsDelect == true && d.IsDelect == true
                        select new DetailsOutput
            {
                GoodId = a.GoodId,
                GoodName = a.GoodName,
                Title = a.Title,
                Content = a.Content,
                CategoryId = c.CategoryID,
                CategoryName = c.CategoryName,
                ImagesUrl = GetGoodImages(goodid),
                ChlidClass = GetChild(goodid, ""),
            }).FirstOrDefault();

            EF.Goods.FirstOrDefault(a => a.GoodId == goodid).VisitCount += 1;
            EF.SaveChanges();
            return(data);
        }
예제 #3
0
        public List <ShoppingCarOutput> fanShoppingCar(string goodid, string userid)
        {
            var data = EF.ShoppingCars.FirstOrDefault(a => a.GoodId == goodid && a.UserId == userid);

            if (data != null)
            {
                var dui = !data.IsDelect;
                //data.IsDelect = dui;
                data.IsDelect = dui;
            }
            if (EF.SaveChanges() > 0)
            {
                return(GetShoppingCarList(userid));
                //return null;
            }
            return(null);
        }
예제 #4
0
        /// <summary>
        /// 点击顶部分类栏
        /// </summary>
        /// <param name="number"></param>
        /// <param name="gsid"></param>
        /// <returns></returns>
        public List <DetailsOutput> CagegoryClick(string number, string gsid)
        {
            var catePid  = EF.GoodCategories.FirstOrDefault(a => a.CategoryID == number && a.IsDelect == true).ParentId;
            var list     = EF.Goods.Where(a => a.CategoryID == number && a.IsDelect == true).ToList();
            var goodlist = new List <DetailsOutput>();

            if (catePid == "")
            {
                goodlist = (from a in EF.Goods
                            join c in EF.GoodCategories on a.CategoryID equals c.CategoryID
                            join d in EF.Good_Specifications on a.CategoryID equals d.GoodId
                            where a.GoodId == number && d.ParentId == "" && a.IsDelect == true && c.IsDelect == true && d.IsDelect == true
                            select new DetailsOutput
                {
                    GoodId = a.GoodId,
                    GoodName = a.GoodName,
                    Title = a.Title,
                    Content = a.Content,
                    CategoryId = a.CategoryID,
                    CategoryName = c.CategoryName,
                    ImagesUrl = GetGoodImages(a.GoodId),
                    ChlidClass = GetChild(number, ""),
                }).ToList();
                foreach (var item in EF.GoodCategories.Where(a => a.ParentId == number))
                {
                    var categoodlist = EF.Goods.Where(a => a.CategoryID == item.CategoryID).ToList();
                    list.AddRange(categoodlist);
                }
            }
            else if (list.Count == 1)
            {
                goodlist = (from a in EF.Goods
                            join c in EF.GoodCategories on a.CategoryID equals c.CategoryID
                            join d in EF.Good_Specifications on a.CategoryID equals d.GoodId
                            where a.CategoryID == number && d.ParentId == "" && a.IsDelect == true && c.IsDelect == true && d.IsDelect == true
                            select new DetailsOutput
                {
                    GoodId = a.GoodId,
                    GoodName = a.GoodName,
                    Title = a.Title,
                    Content = a.Content,
                    CategoryId = c.CategoryID,
                    CategoryName = c.CategoryName,
                    ImagesUrl = GetGoodImages(a.GoodId),
                    ChlidClass = GetChild(number, ""),
                }).ToList();
                EF.Goods.FirstOrDefault(a => a.GoodId == goodlist.FirstOrDefault().GoodId).VisitCount += 1;
                EF.SaveChanges();
            }
            else if (list.Count == 0)
            {
                var buying = EF.GoodPromotions.Where(a => a.PromotionId == number).ToList();
                if (buying.Count == 0)
                {
                    goodlist = (from a in EF.Goods
                                join c in EF.GoodCategories on a.CategoryID equals c.CategoryID
                                join d in EF.Good_Specifications on a.CategoryID equals d.GoodId
                                where a.GoodId == number && d.ParentId == "" && a.IsDelect == true && c.IsDelect == true
                                select new DetailsOutput
                    {
                        GoodId = a.GoodId,
                        GoodName = a.GoodName,
                        Title = a.Title,
                        Content = a.Content,
                        CategoryId = c.CategoryID,
                        CategoryName = c.CategoryName,
                        ImagesUrl = GetGoodImages(a.GoodId),
                        ChlidClass = GetChild(number, ""),
                    }).ToList();
                    EF.Goods.FirstOrDefault(a => a.GoodId == goodlist.FirstOrDefault().GoodId).VisitCount += 1;
                    EF.SaveChanges();
                }
                else
                {
                    goodlist = (from a in EF.Goods
                                join b in EF.Good_Promotions on a.GoodId equals b.GoodId
                                join c in EF.GoodPromotions on b.PromotionId equals c.PromotionId
                                join d in EF.Good_Specifications on a.CategoryID equals d.GoodId
                                where a.GoodId == number && d.ParentId == "" && a.IsDelect == true && c.IsDelect == true && d.IsDelect == true
                                select new DetailsOutput
                    {
                        GoodId = a.GoodId,
                        GoodName = a.GoodName,
                        Title = a.Title,
                        Content = a.Content,
                        CategoryId = a.CategoryID,
                        CategoryName = EF.GoodCategories.FirstOrDefault(x => x.CategoryID == x.CategoryID).CategoryName,
                        ImagesUrl = GetGoodImages(a.GoodId),
                        ChlidClass = GetChild(number, ""),
                    }).ToList();
                }
            }

            return(goodlist);
        }