Ejemplo n.º 1
0
        public CResult <bool> UpdateUser(WebUser webUser)
        {
            LogHelper.Info(MethodBase.GetCurrentMethod().ToString());
            LogHelper.Info("webUser", webUser);

            using (var context = new DeviceMgmtEntities())
            {
                var entity = context.User.FirstOrDefault(t => t.UserID == webUser.ID);
                if (entity == null)
                {
                    return(new CResult <bool>(false, ErrorCode.DataNoExist));
                }

                entity.Address   = webUser.Address;
                entity.Email     = webUser.Email;
                entity.Name      = webUser.UserName;
                entity.Telephone = webUser.TelPhone;
                entity.Moblie    = webUser.Moblie;
                entity.Role      = (int)webUser.Role;

                context.Entry(entity).State = EntityState.Modified;
                LoggerBLL.AddLog(context, webUser.CreateUserID, entity.ProjectID, OperatTypeEnum.修改, _businessModel, "用户名:" + entity.LoginName);

                return(context.Save());
            }
        }
Ejemplo n.º 2
0
        public CResult <bool> DeleteUserByID(string userID, string operatorUserID)
        {
            LogHelper.Info(MethodBase.GetCurrentMethod().ToString());
            LogHelper.Info("userID", userID);

            if (string.IsNullOrWhiteSpace(userID) || string.IsNullOrWhiteSpace(operatorUserID))
            {
                return(new Common.CResult <bool>(false, ErrorCode.ParameterError));
            }

            using (var context = new DeviceMgmtEntities())
            {
                var entity = context.User.FirstOrDefault(t => t.IsValid && t.UserID == userID);
                if (entity != null)
                {
                    if (entity.Role == (int)RoleType.项目管理员)
                    {
                        return(new CResult <bool>(false, ErrorCode.ProjectAdminCannotDelete));
                    }

                    entity.IsValid = false;

                    LoggerBLL.AddLog(context, userID, entity.ProjectID, OperatTypeEnum.除, _businessModel, "用户名:" + entity.LoginName);

                    return(context.Save());
                }
                else
                {
                    return(new CResult <bool>(false, ErrorCode.DataNoExist));
                }
            }
        }