Beispiel #1
0
        public bool Update()
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    UserReceipts model = context.UserReceipts.Find(this.Id);

                    if (model != null)
                    {
                        model.ProvinceId = this.ProvinceId;
                        model.CityId     = this.CityId;
                        model.AreaId     = this.AreaId;
                        model.Address    = this.Address;
                        model.Contact    = this.Contact;
                        model.Phone      = this.Phone;
                        model.ZipCode    = this.ZipCode;

                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id      = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    UserIntegrals model = new UserIntegrals
                    {
                        Id       = this.Id,
                        SourceId = this.SourceId,
                        UserId   = this.UserId,
                        Integral = this.Integral,
                        AddDate  = this.AddDate
                    };

                    context.UserIntegrals.Add(model);
                    context.SaveChanges();
                }

                return(WMUsers.UpdateIntegral(this.UserId, this.Integral));
            }

            return(false);
        }
Beispiel #3
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id      = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    UserReceipts model = new UserReceipts {
                        Id         = this.Id,
                        UserId     = this.UserId,
                        ProvinceId = this.ProvinceId,
                        CityId     = this.CityId,
                        AreaId     = this.AreaId,
                        Address    = this.Address,
                        Contact    = this.Contact,
                        Phone      = this.Phone,
                        ZipCode    = this.ZipCode,
                        AddDate    = this.AddDate
                    };

                    context.UserReceipts.Add(model);
                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #4
0
        public static bool UpdateStatus(string id, int stateId)
        {
            if (!General.IsNullable(id) && stateId > 0)
            {
                using (WMContext context = new WMContext())
                {
                    Goods model = context.Goods.Find(id);

                    if (model != null)
                    {
                        model.StatusId = stateId;

                        //恢复上架的商品,上架时间从恢复之时算起
                        if (stateId == 503)
                        {
                            model.AddDate = DateTime.Now;
                        }

                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #5
0
        public static bool Clear(string userId)
        {
            if (!General.IsNullable(userId))
            {
                using (WMContext context = new WMContext())
                {
                    var list = (
                        from car in context.ShopCars
                        where car.UserId.Equals(userId)
                        select car
                    );

                    if (list != null)
                    {
                        foreach (var item in list)
                            context.ShopCars.Remove(item);

                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #6
0
        public static bool Delete(string id)
        {
            if (!General.IsNullable(id))
            {
                string fileName = null;

                using (WMContext context = new WMContext())
                {
                    GoodBrands model = context.GoodBrands.Find(id);

                    if (model != null)
                    {
                        if (!General.IsNullable(model.Logo))
                            fileName = "~" + model.Logo;

                        context.GoodBrands.Remove(model);
                        context.SaveChanges();
                    }
                }

                if (!General.IsNullable(fileName))
                    return Jumpcity.IO.FileHelper.DeleteFile(fileName);

                return true;
            }

            return false;
        }
Beispiel #7
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id      = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    UserBonus model = new UserBonus {
                        Id       = this.Id,
                        UserId   = this.UserId,
                        OrderId  = this.OrderId,
                        BonusSum = this.BonusSum,
                        AddDate  = this.AddDate
                    };

                    context.UserBonus.Add(model);
                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #8
0
        public static bool UpdateCover(string id)
        {
            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    GoodImages model = context.GoodImages.Find(id);

                    if (model != null)
                    {
                        GoodImages old = context.GoodImages.Where(gi => gi.GoodId.Equals(model.GoodId) && gi.IsCover).FirstOrDefault();
                        if (old != null)
                        {
                            old.IsCover = false;
                        }
                        model.IsCover = true;

                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #9
0
        /// <summary>
        /// 用购物车的数据填充订单商品表
        /// </summary>
        /// <param name="orderId">订单ID</param>
        /// <param name="shopCars">购物车数据</param>
        /// <returns>添加成功返回TRUE,否则返回FALSE</returns>
        public static bool AddList(string orderId, List<WMShopCars> shopCars)
        {
            if (!General.IsNullable(orderId) && !General.IsNullable(shopCars))
            {
                WMOrderGoods model = null;
                using (WMContext context = new WMContext())
                {
                    foreach (WMShopCars item in shopCars)
                    {
                        model = new WMOrderGoods {
                            Id = General.UniqueString(),
                            OrderId = orderId,
                            GoodId = item.GoodId,
                            Price = item.Price,
                            Count = item.Count
                        };

                        context.OrderGoods.Add(model);
                    }

                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }
Beispiel #10
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id      = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    Users model = new Users {
                        Id       = this.Id,
                        RoleId   = this.RoleId,
                        OpenId   = this.OpenId,
                        UserName = this.UserName,
                        Password = this.Password,
                        NickName = this.NickName,
                        Image    = this.Image,
                        Mobile   = this.Mobile,
                        BankCard = this.BankCard,
                        StatusId = this.StatusId,
                        AddDate  = this.AddDate
                    };

                    context.Users.Add(model);
                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #11
0
        public static bool Delete(string id)
        {
            if (!General.IsNullable(id))
            {
                string fileName = null;

                using (WMContext context = new WMContext())
                {
                    GoodBrands model = context.GoodBrands.Find(id);

                    if (model != null)
                    {
                        if (!General.IsNullable(model.Logo))
                        {
                            fileName = "~" + model.Logo;
                        }

                        context.GoodBrands.Remove(model);
                        context.SaveChanges();
                    }
                }

                if (!General.IsNullable(fileName))
                {
                    return(Jumpcity.IO.FileHelper.DeleteFile(fileName));
                }

                return(true);
            }

            return(false);
        }
Beispiel #12
0
        public bool Delete(string id)
        {
            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    var list = (
                        from gc in context.GoodCategories
                        where gc.Id.Equals(id) ||
                        gc.ParentId.Equals(id)
                        select gc
                        );

                    if (list != null)
                    {
                        foreach (var model in list)
                        {
                            context.GoodCategories.Remove(model);
                        }

                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #13
0
        public bool Update()
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    Goods model = context.Goods.Find(this.Id);

                    if (model != null)
                    {
                        model.CategoryId    = this.CategoryId;
                        model.BrandId       = this.BrandId;
                        model.Name          = this.Name;
                        model.OriginalPrice = this.OriginalPrice;
                        model.PresentPrice  = this.PresentPrice;
                        model.Unit          = this.Unit;
                        model.Desc          = this.Desc;
                        model.Spec          = this.Spec;
                        model.Service       = this.Service;
                        model.Integral      = this.Integral;
                        model.Clicks        = this.Clicks;
                        model.Saves         = this.Saves;
                        model.Bonus         = this.Bonus;
                        model.GoldPool      = this.GoldPool;
                        model.StatusId      = this.StatusId;

                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #14
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    Administartors model = new Administartors {
                        RoleId   = this.RoleId,
                        UserName = this.UserName,
                        Password = this.Password,
                        StatusId = this.StatusId,
                        AddDate  = this.AddDate
                    };

                    context.Administartors.Add(model);
                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #15
0
        public bool Update(bool updatePwd = false)
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    Users model = context.Users.Find(this.Id);

                    if (model != null)
                    {
                        model.UserName = this.UserName;
                        model.RoleId   = this.RoleId;
                        model.NickName = this.NickName;
                        model.Integral = this.Integral;
                        model.Image    = this.Image;
                        model.Mobile   = this.Mobile;
                        model.BankCard = this.BankCard;
                        model.StatusId = this.StatusId;
                        if (updatePwd)
                        {
                            model.Password = this.Password;
                        }

                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #16
0
        public static bool Clear(string userId)
        {
            if (!General.IsNullable(userId))
            {
                using (WMContext context = new WMContext())
                {
                    var list = (
                        from car in context.ShopCars
                        where car.UserId.Equals(userId)
                        select car
                        );

                    if (list != null)
                    {
                        foreach (var item in list)
                        {
                            context.ShopCars.Remove(item);
                        }

                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #17
0
        /// <summary>
        /// 用购物车的数据填充订单商品表
        /// </summary>
        /// <param name="orderId">订单ID</param>
        /// <param name="shopCars">购物车数据</param>
        /// <returns>添加成功返回TRUE,否则返回FALSE</returns>
        public static bool AddList(string orderId, List <WMShopCars> shopCars)
        {
            if (!General.IsNullable(orderId) && !General.IsNullable(shopCars))
            {
                WMOrderGoods model = null;
                using (WMContext context = new WMContext())
                {
                    foreach (WMShopCars item in shopCars)
                    {
                        model = new WMOrderGoods {
                            Id      = General.UniqueString(),
                            OrderId = orderId,
                            GoodId  = item.GoodId,
                            Price   = item.Price,
                            Count   = item.Count
                        };

                        context.OrderGoods.Add(model);
                    }

                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #18
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);

                using (WMContext context = new WMContext())
                {
                    OrderGoods model = new OrderGoods {
                        Id      = this.Id,
                        OrderId = this.OrderId,
                        GoodId  = this.GoodId,
                        Price   = this.Price,
                        Count   = this.Count
                    };

                    context.OrderGoods.Add(model);
                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #19
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id      = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    this.IsCover = (context.GoodImages.Where(gi => gi.GoodId.Equals(this.GoodId)).Count() == 0);

                    GoodImages model = new GoodImages {
                        Id      = this.Id,
                        GoodId  = this.GoodId,
                        URL     = this.URL,
                        IsCover = this.IsCover,
                        AddDate = this.AddDate
                    };

                    context.GoodImages.Add(model);
                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #20
0
        /// <summary>
        /// 为指定的订单付款,并将相应的购买积分添加到用户的账户中
        /// </summary>
        /// <param name="orderId">要付款的订单ID</param>
        /// <returns>付款成功返回TRUE,否则返回FALSE</returns>
        public static bool Payment(string orderId)
        {
            bool flag = false;

            if (!General.IsNullable(orderId))
            {
                string userId = null;

                using (WMContext context = new WMContext())
                {
                    Orders model = context.Orders.Find(orderId);

                    if (model != null)
                    {
                        userId     = model.UserId;
                        model.Paid = true;
                        context.SaveChanges();
                        flag = true;
                    }
                }

                if (flag && !General.IsNullable(userId))
                {
                    int inteSum = WMOrderGoods.GetIntegralSum(orderId);
                    return(new WMUserIntegrals {
                        UserId = userId,
                        Integral = inteSum
                    }.Add());
                }
            }

            return(flag);
        }
Beispiel #21
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    UserSets model = (
                        from us in context.UserSets
                        where us.TypeId == this.TypeId &&
                        us.UserId.Equals(this.UserId) &&
                        us.GoodId.Equals(this.GoodId)
                        select us
                        ).FirstOrDefault();

                    if (model != null)
                    {
                        model.AddDate = this.AddDate;
                    }
                    else
                    {
                        model = new UserSets
                        {
                            Id      = General.UniqueString(this.Id),
                            TypeId  = this.TypeId,
                            UserId  = this.UserId,
                            GoodId  = this.GoodId,
                            AddDate = this.AddDate
                        };

                        context.UserSets.Add(model);

                        if (this.TypeId == 401)
                        {
                            //商品的被收藏数量获得递增
                            Goods good = context.Goods.Find(this.GoodId);
                            if (good != null)
                            {
                                good.Saves++;
                            }
                        }
                    }

                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #22
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);

                using (WMContext context = new WMContext())
                {
                    GoodCategories model = new GoodCategories
                    {
                        Id       = this.Id,
                        ParentId = this.ParentId,
                        Name     = this.Name,
                        Level    = 1,
                        Sort     = 0
                    };

                    GoodCategories level = context.GoodCategories.Find(this.ParentId);
                    if (level == null)
                    {
                        model.Level = 1;
                    }
                    else
                    {
                        model.Level = level.Level + 1;
                    }

                    var sort = context.GoodCategories.Where(gc => gc.ParentId.Equals(this.ParentId)).ToList();
                    if (General.IsNullable(sort))
                    {
                        model.Sort = 1;
                    }
                    else
                    {
                        model.Sort = sort.Max(gc => gc.Sort) + 1;
                    }

                    context.GoodCategories.Add(model);
                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #23
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id      = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    Goods good = context.Goods.Find(this.GoodId);

                    if (good != null)
                    {
                        UserClicks model = (
                            from uc in context.UserClicks
                            where uc.PromoterId.Equals(this.PromoterId) &&
                            uc.CustomerId.Equals(this.CustomerId) &&
                            uc.GoodId.Equals(this.GoodId)
                            select uc
                            ).FirstOrDefault();

                        if (model == null)
                        {
                            model = new UserClicks
                            {
                                Id         = this.Id,
                                PromoterId = this.PromoterId,
                                CustomerId = this.CustomerId,
                                GoodId     = this.GoodId,
                                AddDate    = this.AddDate
                            };

                            good.Clicks++;
                            context.UserClicks.Add(model);
                            context.SaveChanges();
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
Beispiel #24
0
        public static bool Delete(string userId)
        {
            if (!General.IsNullable(userId))
            {
                using (WMContext context = new WMContext())
                {
                    Users model = context.Users.Find(userId);

                    if (model != null)
                    {
                        model.StatusId = 203;
                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #25
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id      = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    ShopCars model = (
                        from car in context.ShopCars
                        where car.UserId.Equals(this.UserId) &&
                        car.GoodId.Equals(this.GoodId)
                        select car
                        ).FirstOrDefault();

                    if (model != null)
                    {
                        model.Price  = this.Price;
                        model.Count += this.Count;
                    }
                    else
                    {
                        model = new ShopCars {
                            Id      = this.Id,
                            GoodId  = this.GoodId,
                            UserId  = this.UserId,
                            Price   = this.Price,
                            Count   = this.Count,
                            AddDate = this.AddDate
                        };

                        context.ShopCars.Add(model);
                    }

                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #26
0
        public static bool Delete(int adminId)
        {
            if (adminId > 0)
            {
                using (WMContext context = new WMContext())
                {
                    Administartors model = context.Administartors.Find(adminId);

                    if (model != null)
                    {
                        model.StatusId = 203;
                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #27
0
        public static bool Delete(string userId)
        {
            if (!General.IsNullable(userId))
            {
                using (WMContext context = new WMContext())
                {
                    Users model = context.Users.Find(userId);

                    if (model != null)
                    {
                        model.StatusId = 203;
                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #28
0
        public static bool UpdateIntegral(string userId, int addInte)
        {
            if (!General.IsNullable(userId))
            {
                using (WMContext context = new WMContext())
                {
                    Users model = context.Users.Find(userId);

                    if (model != null)
                    {
                        model.Integral += addInte;
                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #29
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id      = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                if (!this.PresentPrice.HasValue)
                {
                    this.PresentPrice = this.OriginalPrice;
                }

                using (WMContext context = new WMContext())
                {
                    Goods model = new Goods {
                        Id            = this.Id,
                        CategoryId    = this.CategoryId,
                        BrandId       = this.BrandId,
                        Name          = this.Name,
                        OriginalPrice = this.OriginalPrice,
                        PresentPrice  = this.PresentPrice,
                        Unit          = this.Unit,
                        Desc          = this.Desc,
                        Spec          = this.Spec,
                        Service       = this.Service,
                        Integral      = this.Integral,
                        Clicks        = this.Clicks,
                        Saves         = this.Saves,
                        Bonus         = this.Bonus,
                        GoldPool      = this.GoldPool,
                        StatusId      = this.StatusId,
                        AddDate       = this.AddDate
                    };

                    context.Goods.Add(model);
                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
Beispiel #30
0
        public static bool Delete(int adminId)
        {
            if (adminId > 0)
            {
                using (WMContext context = new WMContext())
                {
                    Administartors model = context.Administartors.Find(adminId);

                    if (model != null)
                    {
                        model.StatusId = 203;
                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #31
0
        public static bool UpdateStatus(string orderId, int state)
        {
            if (!General.IsNullable(orderId) && state > 0)
            {
                using (WMContext context = new WMContext())
                {
                    Orders model = context.Orders.Find(orderId);

                    if (model != null)
                    {
                        model.StatusId = state;
                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #32
0
        public static bool Delete(string id)
        {
            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    UserSets model = context.UserSets.Find(id);

                    if (model != null)
                    {
                        context.UserSets.Remove(model);
                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #33
0
        public static bool Delete(string id)
        {
            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    UserIntegrals model = context.UserIntegrals.Find(id);

                    if (model != null)
                    {
                        context.UserIntegrals.Remove(model);
                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #34
0
        public static bool Delete(string id)
        {
            if (!General.IsNullable(id))
            {
                string fileName = null;

                using (WMContext context = new WMContext())
                {
                    GoodImages model = context.GoodImages.Find(id);

                    if (model != null)
                    {
                        fileName = "~" + model.URL;
                        GoodImages newCover = null;

                        if (model.IsCover)
                        {
                            newCover = (
                                from gi in context.GoodImages
                                where gi.GoodId.Equals(model.GoodId) &&
                                gi.Id != model.Id
                                orderby gi.AddDate descending
                                select gi
                                ).FirstOrDefault();

                            if (newCover != null)
                            {
                                newCover.IsCover = true;
                            }
                        }

                        context.GoodImages.Remove(model);
                        context.SaveChanges();
                    }
                }

                return(FileHelper.DeleteFile(fileName));
            }

            return(false);
        }
Beispiel #35
0
        public bool Update()
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    GoodBrands model = context.GoodBrands.Find(this.Id);

                    if (model != null)
                    {
                        model.Name = this.Name;
                        model.Logo = this.Logo;
                        model.URL  = this.URL;

                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #36
0
        public bool Update()
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    Administartors model = context.Administartors.Find(this.Id);

                    if (model != null)
                    {
                        model.UserName = this.UserName;
                        model.Password = this.Password;
                        model.RoleId   = this.RoleId;
                        model.StatusId = this.StatusId;
                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #37
0
        public static bool Delete(string id)
        {
            if (!General.IsNullable(id))
            {
                string fileName = null;

                using (WMContext context =new WMContext())
                {
                    GoodImages model = context.GoodImages.Find(id);

                    if (model != null)
                    {
                        fileName = "~" + model.URL;
                        GoodImages newCover = null;

                        if (model.IsCover)
                        {
                            newCover = (
                                from gi in context.GoodImages
                                where gi.GoodId.Equals(model.GoodId)
                                   && gi.Id != model.Id
                                orderby gi.AddDate descending
                                select gi
                            ).FirstOrDefault();

                            if (newCover != null)
                                newCover.IsCover = true;
                        }

                        context.GoodImages.Remove(model);
                        context.SaveChanges();
                    }
                }

                return FileHelper.DeleteFile(fileName);
            }

            return false;
        }
Beispiel #38
0
        public static bool UpdateCover(string id)
        {
            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    GoodImages model = context.GoodImages.Find(id);

                    if (model != null)
                    {
                        GoodImages old = context.GoodImages.Where(gi => gi.GoodId.Equals(model.GoodId) && gi.IsCover).FirstOrDefault();
                        if (old != null)
                            old.IsCover = false;
                        model.IsCover = true;

                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #39
0
        /// <summary>
        /// 为指定的订单付款,并将相应的购买积分添加到用户的账户中
        /// </summary>
        /// <param name="orderId">要付款的订单ID</param>
        /// <returns>付款成功返回TRUE,否则返回FALSE</returns>
        public static bool Payment(string orderId)
        {
            bool flag = false;

            if (!General.IsNullable(orderId))
            {
                string userId = null;

                using (WMContext context = new WMContext())
                {
                    Orders model = context.Orders.Find(orderId);

                    if (model != null)
                    {
                        userId = model.UserId;
                        model.Paid = true;
                        context.SaveChanges();
                        flag = true;
                    }
                }

                if (flag && !General.IsNullable(userId))
                {
                    int inteSum = WMOrderGoods.GetIntegralSum(orderId);
                    return new WMUserIntegrals {
                        UserId = userId,
                        Integral = inteSum
                    }.Add();
                }
            }

            return flag;
        }
Beispiel #40
0
        public static bool UpdateStatus(string id, int stateId)
        {
            if (!General.IsNullable(id) && stateId > 0)
            {
                using (WMContext context = new WMContext())
                {
                    Goods model = context.Goods.Find(id);

                    if (model != null)
                    {
                        model.StatusId = stateId;

                        //恢复上架的商品,上架时间从恢复之时算起
                        if (stateId == 503)
                            model.AddDate = DateTime.Now;

                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #41
0
        public bool Update()
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    Goods model = context.Goods.Find(this.Id);

                    if (model != null)
                    {
                        model.CategoryId = this.CategoryId;
                        model.BrandId = this.BrandId;
                        model.Name = this.Name;
                        model.OriginalPrice = this.OriginalPrice;
                        model.PresentPrice = this.PresentPrice;
                        model.Unit = this.Unit;
                        model.Desc = this.Desc;
                        model.Spec = this.Spec;
                        model.Service = this.Service;
                        model.Integral = this.Integral;
                        model.Clicks = this.Clicks;
                        model.Saves = this.Saves;
                        model.Bonus = this.Bonus;
                        model.GoldPool = this.GoldPool;
                        model.StatusId = this.StatusId;

                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #42
0
        public bool Update(bool updatePwd = false)
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    Users model = context.Users.Find(this.Id);

                    if (model != null)
                    {
                        model.UserName = this.UserName;
                        model.RoleId = this.RoleId;
                        model.NickName = this.NickName;
                        model.Integral = this.Integral;
                        model.Image = this.Image;
                        model.Mobile = this.Mobile;
                        model.BankCard = this.BankCard;
                        model.BankName = this.BankName;
                        model.StatusId = this.StatusId;
                        if (updatePwd)
                            model.Password = this.Password;

                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #43
0
        public static bool UpdatePassword(string userId, string oldPwd, string newPwd)
        {
            if (!General.IsNullable(userId) && !General.IsNullable(oldPwd) && !General.IsNullable(newPwd))
            {
                using (WMContext context = new WMContext())
                {
                    Users model = context.Users.Where(u => u.Id.Equals(userId) && u.Password.Equals(oldPwd)).FirstOrDefault();

                    if (model != null && !oldPwd.Equals(newPwd))
                    {
                        model.Password = newPwd;
                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #44
0
        public static bool UpdateIntegral(string userId, int addInte)
        {
            if (!General.IsNullable(userId))
            {
                using (WMContext context = new WMContext())
                {
                    Users model = context.Users.Find(userId);

                    if (model != null)
                    {
                        model.Integral += addInte;
                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #45
0
        /// <summary>
        /// 更新订单的当前状态
        /// </summary>
        /// <param name="orderId">要更新的订单号</param>
        /// <param name="state">要更新到的订单状态ID</param>
        /// <returns>更新成功返回True,否则返回False</returns>
        public static bool UpdateStatus(string orderId, int state)
        {
            if (!General.IsNullable(orderId) && state > 0)
            {
                using (WMContext context = new WMContext())
                {
                    Orders model = context.Orders.Find(orderId);

                    if (model != null)
                    {
                        model.StatusId = state;
                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #46
0
        /// <summary>
        /// 为指定的订单付款,将相应的购买积分添加到购买者的账户中,并保存相应分红信息记录(如果存在推广者的话)
        /// </summary>
        /// <param name="orderId">要付款的订单ID</param>
        /// <param name="bounsUserId">设置可获得订单分红的推广者ID(如果有的话)</param>
        /// <returns>付款成功返回TRUE。订单已支付、或者由于各种原因造成的付款失败都返回FALSE</returns>
        public static bool Payment(string orderId, string bounsUserId = null)
        {
            bool flag = false;

            if (!General.IsNullable(orderId))
            {
                string userId = null;

                using (WMContext context = new WMContext())
                {
                    Orders model = context.Orders.Find(orderId);

                    if (model != null && !model.Paid)
                    {
                        userId = model.UserId;
                        model.Paid = true;
                        context.SaveChanges();
                        flag = true;
                    }
                }

                if (flag && !General.IsNullable(userId))
                {
                    new WMUserIntegrals {
                        UserId = userId,
                        Integral = WMOrderGoods.GetTotalIntegral(orderId)
                    }.Add();

                    if (!General.IsNullable(bounsUserId))
                    {
                        new WMUserBonus
                        {
                            UserId = bounsUserId,
                            OrderId = orderId,
                            BonusSum = WMOrderGoods.GetTotalBonus(orderId)
                        }.Add();
                    }
                }
            }

            return flag;
        }
Beispiel #47
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);

                using (WMContext context = new WMContext())
                {
                    GoodBrands model = new GoodBrands {
                        Id = this.Id,
                        Name = this.Name,
                        Logo = this.Logo,
                        URL = this.URL
                    };

                    context.GoodBrands.Add(model);
                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }
Beispiel #48
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    UserSets model = (
                        from us in context.UserSets
                        where us.TypeId == this.TypeId
                            && us.UserId.Equals(this.UserId)
                            && us.GoodId.Equals(this.GoodId)
                        select us
                    ).FirstOrDefault();

                    if (model != null)
                        model.AddDate = this.AddDate;
                    else
                    {
                        model = new UserSets
                        {
                            Id = General.UniqueString(this.Id),
                            TypeId = this.TypeId,
                            UserId = this.UserId,
                            GoodId = this.GoodId,
                            AddDate = this.AddDate
                        };

                        context.UserSets.Add(model);

                        if (this.TypeId == 401)
                        {
                            //商品的被收藏数量获得递增
                            Goods good = context.Goods.Find(this.GoodId);
                            if (good != null)
                                good.Saves++;
                        }
                    }

                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }
Beispiel #49
0
        /// <summary>
        /// 添加新的购物车信息,如果购物信息已存在,则追加相应购买数量
        /// </summary>
        /// <returns>操作成功返回True,否则返回False</returns>
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    ShopCars model = (
                        from car in context.ShopCars
                        where car.UserId.Equals(this.UserId)
                           && car.GoodId.Equals(this.GoodId)
                        select car
                    ).FirstOrDefault();

                    if (model != null)
                    {
                        model.Price = this.Price;
                        model.Count += this.Count;
                    }
                    else
                    {
                        model = new ShopCars {
                            Id = this.Id,
                            GoodId = this.GoodId,
                            UserId = this.UserId,
                            Price = this.Price,
                            Count = this.Count,
                            AddDate = this.AddDate
                        };

                        context.ShopCars.Add(model);
                    }

                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }
Beispiel #50
0
        /// <summary>
        /// 更新购物车内指定购买信息的商品数量
        /// </summary>
        /// <param name="id">设置要更新的购买信息ID</param>
        /// <param name="count">设置要更新的数量</param>
        /// <param name="isAppend">设置是否是追加数量的操作,默认为False</param>
        /// <returns>更新成功返回True,否则返回False</returns>
        public static bool UpdateCount(string id, int count, bool isAppend = false)
        {
            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    ShopCars model = context.ShopCars.Find(id);

                    if (model != null)
                    {
                        if (isAppend && (model.Count + count) > 0)
                            model.Count += count;
                        else if (!isAppend && count > 0)
                            model.Count = count;
                        else
                            return false;

                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #51
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                if (!this.PresentPrice.HasValue)
                    this.PresentPrice = this.OriginalPrice;

                using (WMContext context = new WMContext())
                {
                    Goods model = new Goods {
                        Id = this.Id,
                        CategoryId = this.CategoryId,
                        BrandId = this.BrandId,
                        Name = this.Name,
                        OriginalPrice = this.OriginalPrice,
                        PresentPrice = this.PresentPrice,
                        Unit = this.Unit,
                        Desc = this.Desc,
                        Spec = this.Spec,
                        Service = this.Service,
                        Integral = this.Integral,
                        Clicks = this.Clicks,
                        Saves = this.Saves,
                        Bonus = this.Bonus,
                        GoldPool = this.GoldPool,
                        StatusId = this.StatusId,
                        AddDate = this.AddDate
                    };

                    context.Goods.Add(model);
                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }
Beispiel #52
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    this.IsCover = (context.GoodImages.Where(gi => gi.GoodId.Equals(this.GoodId)).Count() == 0);

                    GoodImages model = new GoodImages {
                        Id = this.Id,
                        GoodId = this.GoodId,
                        URL = this.URL,
                        IsCover = this.IsCover,
                        AddDate = this.AddDate
                    };

                    context.GoodImages.Add(model);
                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }
Beispiel #53
0
        public bool Update()
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    GoodBrands model = context.GoodBrands.Find(this.Id);

                    if (model != null)
                    {
                        model.Name = this.Name;
                        model.Logo = this.Logo;
                        model.URL = this.URL;

                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #54
0
        /// <summary>
        /// 更新当前订单的速递单号、负责配送速递公司名称以及当前的订单状态
        /// </summary>
        /// <returns>更新成功返回True,否则返回False</returns>
        public bool Update()
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    Orders model = context.Orders.Find(this.Id);

                    if (model != null)
                    {
                        model.ExpressId = this.ExpressId;
                        model.OddNumber = this.OddNumber;
                        model.StatusId = this.StatusId;
                        context.SaveChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #55
0
        public static bool UpdateOpenId(string userId, string openId, string unionId)
        {
            if (!General.IsNullable(userId) && !General.IsNullable(openId) && General.IsNullable(unionId))
            {
                using (WMContext context = new WMContext())
                {
                    int count = (
                        from u in context.Users
                        where u.UnionId != null
                           && u.UnionId != ""
                           && u.UnionId.Equals(unionId)
                           && u.Id != userId
                        select u.Id
                    ).Count();

                    if (count == 0)
                    {
                        Users model = context.Users.Find(userId);
                        if (model != null)
                        {
                            model.OpenId = openId;
                            model.UnionId = unionId;
                            context.SaveChanges();
                            return true;
                        }
                    }
                }
            }

            return false;
        }
Beispiel #56
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    UserBonus model = new UserBonus {
                        Id = this.Id,
                        UserId = this.UserId,
                        OrderId = this.OrderId,
                        BonusSum = this.BonusSum,
                        AddDate = this.AddDate
                    };

                    context.UserBonus.Add(model);
                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }
Beispiel #57
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    Users model = new Users {
                        Id = this.Id,
                        RoleId = this.RoleId,
                        OpenId = this.OpenId,
                        UnionId = this.UnionId,
                        UserName = this.UserName,
                        Password = this.Password,
                        NickName = this.NickName,
                        Image = this.Image,
                        Mobile = this.Mobile,
                        BankCard = this.BankCard,
                        BankName = this.BankName,
                        StatusId = this.StatusId,
                        AddDate = this.AddDate
                    };

                    context.Users.Add(model);
                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }
Beispiel #58
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    Goods good = context.Goods.Find(this.GoodId);

                    if (good != null)
                    {
                        UserClicks model = (
                            from uc in context.UserClicks
                            where uc.PromoterId.Equals(this.PromoterId)
                               && uc.CustomerId.Equals(this.CustomerId)
                               && uc.GoodId.Equals(this.GoodId)
                            select uc
                        ).FirstOrDefault();

                        if (model == null)
                        {
                            model = new UserClicks
                            {
                                Id = this.Id,
                                PromoterId = this.PromoterId,
                                CustomerId = this.CustomerId,
                                GoodId = this.GoodId,
                                AddDate = this.AddDate
                            };

                            good.Clicks++;
                            context.UserClicks.Add(model);
                            context.SaveChanges();
                        }
                    }
                }

                return true;
            }

            return false;
        }
Beispiel #59
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = Guid.NewGuid().ToUniqueNumber().ToString();
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    Orders model = new Orders {
                        Id = this.Id,
                        UserId = this.UserId,
                        ProvinceId = this.ProvinceId,
                        CityId = this.CityId,
                        AreaId = this.AreaId,
                        Contact = this.Contact,
                        Address = this.Address,
                        Phone = this.Phone,
                        ZipCode = this.ZipCode,
                        PayId = this.PayId,
                        Paid = this.Paid,
                        Freight = this.Freight,
                        Message = this.Message,
                        StatusId = this.StatusId,
                        AddDate = this.AddDate
                    };

                    context.Orders.Add(model);
                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }
Beispiel #60
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);

                using (WMContext context = new WMContext())
                {
                    OrderGoods model = new OrderGoods {
                        Id = this.Id,
                        OrderId = this.OrderId,
                        GoodId = this.GoodId,
                        Price = this.Price,
                        Count = this.Count
                    };

                    context.OrderGoods.Add(model);
                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }