Beispiel #1
0
        /// <summary>
        /// Update a record
        /// </summary>
        public bool Update(HideUserEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE dbo.HideUsers SET ");
            strSql.Append("UserID=@UserID, ");
            strSql.Append("HideUserIds=@HideUserIds ");
            strSql.Append("WHERE ID=@ID; ");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "UserID", DbType.Int32, model.UserID);
                    db.AddInParameter(dbCommand, "HideUserIds", DbType.String, model.HideUserIds);
                    db.AddInParameter(dbCommand, "ID", DbType.Int32, model.ID);
                    int rows = db.ExecuteNonQuery(dbCommand);
                    if (rows > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]",
                                                    strSql.ToString(), base.FormatParameters(dbCommand.Parameters), ex.Message));
                    return(false);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Add a record
        /// </summary>
        public int Insert(HideUserEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("INSERT  INTO dbo.HideUsers ");
            strSql.Append("( UserID, HideUserIds )");

            strSql.Append("VALUES (@UserID,@HideUserIds); ");
            strSql.Append(";SELECT ISNULL( SCOPE_IDENTITY(),0);");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "UserID", DbType.Int32, model.UserID);
                    db.AddInParameter(dbCommand, "HideUserIds", DbType.String, model.HideUserIds);
                    int    result;
                    object obj = db.ExecuteScalar(dbCommand);
                    if (!int.TryParse(obj.ToString(), out result))
                    {
                        return(0);
                    }
                    return(result);
                }
                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]",
                                                    strSql.ToString(), base.FormatParameters(dbCommand.Parameters), ex.Message));
                    return(0);
                }
            }
        }
Beispiel #3
0
        public HideUserEntity GetHideUserByUserId(int userId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT TOP 1 * FROM dbo.HideUsers AS HU ");
            strSql.Append("WHERE HU.UserID = @UserID; ");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "UserID", DbType.Int32, userId);
                    HideUserEntity model = null;
                    using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                    {
                        if (dataReader.Read())
                        {
                            model = HideUserEntity.ReaderBind(dataReader);
                        }
                    }
                    return(model);
                }
                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]",
                                                    strSql.ToString(), base.FormatParameters(dbCommand.Parameters), ex.Message));
                    return(null);
                }
            }
        }
Beispiel #4
0
        public HideUserEntity GetHideUserByUserId(int userId)
        {
            this.ClearBrokenRuleMessages();
            HideUserEntity hideUserEntity = mgr.GetHideUserByUserId(userId);

            this.AddBrokenRuleMessages(mgr.BrokenRuleMessages);
            return(hideUserEntity);
        }
Beispiel #5
0
        public bool UpdateHideUsers(HideUserEntity hideUser)
        {
            this.ClearBrokenRuleMessages();
            bool updated = mgr.UpdateHideUsers(hideUser);

            this.AddBrokenRuleMessages(mgr.BrokenRuleMessages);
            return(updated);
        }
Beispiel #6
0
        public int AddHideUsers(HideUserEntity hideUser)
        {
            this.ClearBrokenRuleMessages();
            int id = mgr.AddHideUsers(hideUser);

            this.AddBrokenRuleMessages(mgr.BrokenRuleMessages);
            return(id);
        }
Beispiel #7
0
        public bool UpdateHideUsers(HideUserEntity hideUser)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <HideUserEntity> validator = new UpdateHideUserValidator();

            if (!validator.Validate(hideUser))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(false);
            }
            if (!hideUserRepository.Update(hideUser))
            {
                this.AddBrokenRuleMessage();
                return(false);
            }
            return(true);
        }
Beispiel #8
0
        public int AddHideUsers(HideUserEntity hideUser)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <HideUserEntity> validator = new AddHideUserValidator();

            if (!validator.Validate(hideUser))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(0);
            }
            int id = hideUserRepository.Insert(hideUser);

            if (id <= 0)
            {
                this.AddBrokenRuleMessage();
                return(0);
            }
            hideUser.ID = id;
            return(id);
        }
Beispiel #9
0
        private string GetUserTickets(int currentUserId)
        {
            List <RolesEnum> roles = new List <RolesEnum>();

            roles.Add(RolesEnum.PM);
            roles.Add(RolesEnum.DEV);
            roles.Add(RolesEnum.QA);
            roles.Add(RolesEnum.Leader);
            HideUserEntity entity      = userApp.GetHideUserByUserId(currentUserId);
            string         hideUserIds = "";

            if (entity != null)
            {
                hideUserIds = entity.HideUserIds;
            }
            List <UserTicketModel> userTickets = userApp.SearchUserWithRole(roles, hideUserIds);
            string strUserTickets = JsonConvert.SerializeObject(userTickets);

            return(strUserTickets);
        }