当前位置: 首页>>代码示例>>C#>>正文


C# Models.WMContext类代码示例

本文整理汇总了C#中MicroEmall.Models.WMContext的典型用法代码示例。如果您正苦于以下问题:C# WMContext类的具体用法?C# WMContext怎么用?C# WMContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WMContext类属于MicroEmall.Models命名空间,在下文中一共展示了WMContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Delete

        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;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:28,代码来源:WMGoodBrands.cs

示例2: Get

        public static WMOrderGoods Get(string id)
        {
            WMOrderGoods model = null;

            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    model = (
                        from og in context.OrderGoods
                        join g in context.Goods on og.GoodId equals g.Id
                        where og.Id.Equals(id)
                        select new WMOrderGoods
                        {
                            Id = og.Id,
                            OrderId = og.OrderId,
                            GoodId = og.GoodId,
                            GoodName = g.Name,
                            GoodFigure = context.GoodImages.Where(gi => gi.GoodId.Equals(og.GoodId) && gi.IsCover).Select(gi => gi.URL).FirstOrDefault(),
                            GoodInteSubTotal = (g.Integral * og.Count),
                            Price = og.Price,
                            Count = og.Count
                        }
                    ).FirstOrDefault();
                }
            }

            return model;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:29,代码来源:WMOrderGoods.cs

示例3: AddList

        /// <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;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:34,代码来源:WMOrderGoods.cs

示例4: Clear

        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;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:25,代码来源:WMShopCars.cs

示例5: Get

        public static WMAdministrators Get(int adminId)
        {
            WMAdministrators admin = null;

            if (adminId > 0)
            {
                using (WMContext context = new WMContext())
                {
                    admin = (
                        from ad in context.Administartors
                        join r in context.Options on ad.RoleId equals r.Id
                        join s in context.Options on ad.StatusId equals s.Id
                        where ad.Id == adminId
                        select new WMAdministrators
                        {
                            Id = ad.Id,
                            RoleId = ad.RoleId,
                            RoleName = r.Name,
                            UserName = ad.UserName,
                            Password = ad.Password,
                            StatusId = ad.StatusId,
                            StatusName = s.Name,
                            AddDate = ad.AddDate
                        }
                    ).FirstOrDefault();
                }
            }

            return admin;
        }
开发者ID:honj51,项目名称:micro-emall,代码行数:30,代码来源:WMAdministrators.cs

示例6: Get

        public static WMUserSets Get(string id)
        {
            WMUserSets userSet = null;

            if (!General.IsNullable(id))
            {
                DateTime now = DateTime.Now;
                using (WMContext context = new WMContext())
                {
                    userSet = (
                        from us in context.UserSets
                        join g in context.Goods on us.GoodId equals g.Id
                        join t in context.Options on us.TypeId equals t.Id
                        where us.Id.Equals(id)
                        select new WMUserSets
                        {
                            Id = us.Id,
                            TypeId = us.TypeId,
                            TypeName = t.Name,
                            UserId = us.UserId,
                            GoodId = us.GoodId,
                            GoodName = g.Name,
                            GoodFigure = context.GoodImages.Where(gi => gi.GoodId.Equals(us.GoodId) && gi.IsCover).Select(gi => gi.URL).FirstOrDefault(),
                            AddDate = us.AddDate
                        }
                    ).FirstOrDefault();
                }
            }

            return userSet;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:31,代码来源:WMUserSets.cs

示例7: GetList

        public static List<WMOrderExpress> GetList(out int pageCount, string name = null, int pageIndex = 0, int pageSize = 0)
        {
            List<WMOrderExpress> list = null;
            bool isName = !General.IsNullable(name);
            pageCount = 0;

            using (WMContext context = new WMContext())
            {
                var query = (
                    from oe in context.OrderExpress
                    where (isName ? oe.Name.Contains(name) : true)
                    orderby oe.AddDate descending
                    select new WMOrderExpress
                    {
                        Id = oe.Id,
                        Name = oe.Name,
                        URL = oe.URL,
                        AddDate = oe.AddDate
                    }
                );

                if (query != null)
                {
                    pageCount = query.Count();

                    if (pageIndex >= 0 && pageSize > 0)
                        query = query.Skip(pageIndex * pageSize).Take(pageSize);

                    list = query.ToList();
                }
            }

            return list;
        }
开发者ID:honj51,项目名称:micro-emall,代码行数:34,代码来源:WMOrderExpress.cs

示例8: Get

        public static WMUserBonus Get(string id)
        {
            WMUserBonus model = null;

            if (!General.IsNullable(id))
            {
                using(WMContext context = new WMContext())
                {
                    model = (
                        from ub in context.UserBonus
                        where ub.Id.Equals(id)
                        select new WMUserBonus
                        {
                            Id = ub.Id,
                            UserId = ub.UserId,
                            OrderId = ub.OrderId,
                            BonusSum = ub.BonusSum,
                            AddDate = ub.AddDate
                        }
                    ).FirstOrDefault();
                }
            }

            return model;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:25,代码来源:WMUserBonus.cs

示例9: Get

        public static WMGoodImages Get(string id)
        {
            WMGoodImages image = null;

            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    image = (
                        from gi in context.GoodImages
                        where gi.Id.Equals(id)
                        select new WMGoodImages
                        {
                            Id = gi.Id,
                            GoodId = gi.GoodId,
                            URL = gi.URL,
                            IsCover = gi.IsCover,
                            AddDate = gi.AddDate
                        }
                    ).FirstOrDefault();
                }
            }

            return image;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:25,代码来源:WMGoodImages.cs

示例10: Get

        public static UserIntegrals Get(string id)
        {
            UserIntegrals integral = null;

            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    integral = (
                        from ui in context.UserIntegrals
                        join s in context.Options on ui.SourceId equals s.Id
                        where ui.Id.Equals(id)
                        select new WMUserIntegrals
                        {
                            Id = ui.Id,
                            SourceId = ui.SourceId,
                            SourceName = s.Name,
                            UserId = ui.UserId,
                            Integral = ui.Integral,
                            AddDate = ui.AddDate
                        }
                    ).FirstOrDefault();
                }
            }

            return integral;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:27,代码来源:WMUserIntegrals.cs

示例11: GetList

        public static List<WMGoodBrands> GetList(out int pageCount, string name = null, int pageIndex = 0, int pageSize = 0)
        {
            List<WMGoodBrands> list = null;
            bool isName = !General.IsNullable(name);
            pageCount = 0;

            using (WMContext context = new WMContext())
            {
                var query = (
                    from gb in context.GoodBrands
                    where (isName ? gb.Name.Contains(name) : true)
                    orderby gb.Logo descending
                    select new WMGoodBrands
                    {
                        Id = gb.Id,
                        Name = gb.Name,
                        Logo = gb.Logo,
                        URL = gb.URL
                    }
                );

                if (query != null)
                {
                    pageCount = query.Count();

                    if (pageIndex >= 0 && pageSize > 0)
                        query = query.Skip(pageIndex * pageSize).Take(pageSize);

                    list = query.ToList();
                }
            }

            return list;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:34,代码来源:WMGoodBrands.cs

示例12: GetList

        public static List<WMOrderPay> GetList()
        {
            List<WMOrderPay> list = null;

            using (WMContext context = new WMContext())
            {
                list = (
                    from r in context.Options
                    where r.Group.Equals(groupName)
                    select new WMOrderPay
                    {
                        PayId = r.Id,
                        PayName = r.Name
                    }
                ).ToList();
            }

            return list;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:19,代码来源:WMOrderPay.cs

示例13: Delete

        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;
        }
开发者ID:honj51,项目名称:micro-emall,代码行数:19,代码来源:WMAdministrators.cs

示例14: GetList

        public static List<WMGoodState> GetList()
        {
            List<WMGoodState> list = null;

            using (WMContext context = new WMContext())
            {
                list = (
                    from r in context.Options
                    where r.Group.Equals(groupName)
                    select new WMGoodState
                    {
                        StateId = r.Id,
                        StateName = r.Name
                    }
                ).ToList();
            }

            return list;
        }
开发者ID:chinaq,项目名称:micro-emall,代码行数:19,代码来源:WMGoodState.cs

示例15: Delete

        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;
        }
开发者ID:honj51,项目名称:micro-emall,代码行数:19,代码来源:WMUsers.cs


注:本文中的MicroEmall.Models.WMContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。