public bool UpdatePassword(User_Com user_Pass, int?ID, string oldPass)
        {
            try
            {
                using (FBEntities entities = new FBEntities())
                {
                    var user = entities.User_Com.Where(x => x.ID == ID).FirstOrDefault();

                    if (user.Password != oldPass)
                    {
                        return(false);
                    }
                    else
                    {
                        user.Password = user_Pass.Password;
                        entities.SaveChanges();
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public bool changeUserByIdvk(User user)
        {
            try
            {
                var _user = _ctx.USERS.FirstOrDefault(u => u.IDVK == user.IDVK);

                _user.LASTOPENEDQUESTION_ID = user.LASTOPENEDQUESTION_ID == null ? _user.LASTOPENEDQUESTION_ID : user.LASTOPENEDQUESTION_ID;
                _user.ROLE     = user.ROLE == null ? _user.ROLE : user.ROLE;
                _user.STATE    = user.STATE == null ? _user.STATE : user.STATE;
                _user.SUBGROUP = user.SUBGROUP == null ? _user.SUBGROUP : user.SUBGROUP;
                _user.ARG      = user.ARG == null ? _user.ARG : user.ARG;

                _ctx.USERS.Update(_user);
                _ctx.SaveChanges();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }