コード例 #1
0
ファイル: WMUserIntegrals.cs プロジェクト: ooyuan/micro-emall
        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);
        }
コード例 #2
0
ファイル: WMUserIntegrals.cs プロジェクト: ooyuan/micro-emall
        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);
        }
コード例 #3
0
ファイル: WMUserIntegrals.cs プロジェクト: ooyuan/micro-emall
        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);
        }
コード例 #4
0
ファイル: WMUserIntegrals.cs プロジェクト: chinaq/micro-emall
        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;
        }