예제 #1
0
        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
        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
        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
        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;
        }