예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
0
        public static bool UpdatePassword(int adminId, string oldPwd, string newPwd)
        {
            if (adminId > 0 && !General.IsNullable(oldPwd) && !General.IsNullable(newPwd))
            {
                if (oldPwd.Equals(newPwd))
                {
                    return(true);
                }

                using (WMContext context = new WMContext())
                {
                    Administartors model = context.Administartors.Find(adminId);

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

            return(false);
        }
예제 #5
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;
        }