コード例 #1
0
        /// <summary>
        /// Saves this instance.
        /// </summary>
        /// <param name="entity">The project mailbox to save.</param>
        /// <returns></returns>
        public static bool SaveOrUpdate(ProjectMailbox entity)
        {
            if (entity == null) throw new ArgumentNullException("entity");
            if (entity.ProjectId <= Globals.NEW_ID) throw (new ArgumentException("Cannot save milestone, the project id is invalid"));
            if (string.IsNullOrEmpty(entity.Mailbox)) throw (new ArgumentException("The mailbox cannot be empty or null"));

            if (entity.Id > Globals.NEW_ID)
                return DataProviderManager.Provider.UpdateProjectMailbox(entity);

            var tempId = DataProviderManager.Provider.CreateProjectMailbox(entity);

            if (tempId <= 0) return false;

            entity.Id = tempId;
            return true;
        }
コード例 #2
0
        /// <summary>
        /// Updates the project mailbox.
        /// </summary>
        /// <param name="mailboxToUpdate">The mailbox to update.</param>
        /// <returns></returns>
        public override bool UpdateProjectMailbox(ProjectMailbox mailboxToUpdate)
        {
            if (mailboxToUpdate == null) throw new ArgumentNullException("mailboxToUpdate");

            using (var sqlCmd = new SqlCommand())
            {
                SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_PROJECTMAILBOX_UPDATEPROJECTMAILBOX);

                AddParamToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
                AddParamToSqlCmd(sqlCmd, "@ProjectMailboxId", SqlDbType.Int, 0, ParameterDirection.Input, mailboxToUpdate.Id);
                AddParamToSqlCmd(sqlCmd, "@ProjectId", SqlDbType.Int, 0, ParameterDirection.Input, mailboxToUpdate.ProjectId);
                AddParamToSqlCmd(sqlCmd, "@MailBoxEmailAddress", SqlDbType.NVarChar, 0, ParameterDirection.Input, mailboxToUpdate.Mailbox);
                AddParamToSqlCmd(sqlCmd, "@AssignToUserName", SqlDbType.NVarChar, 0, ParameterDirection.Input, mailboxToUpdate.AssignToUserName);
                AddParamToSqlCmd(sqlCmd, "@IssueTypeId", SqlDbType.Int, 0, ParameterDirection.Input, mailboxToUpdate.IssueTypeId);
                AddParamToSqlCmd(sqlCmd, "@CategoryId", SqlDbType.Int, 0, ParameterDirection.Input, mailboxToUpdate.CategoryId);

                ExecuteScalarCmd(sqlCmd);

                return ((int)sqlCmd.Parameters["@ReturnValue"].Value == 0);   
            }
        }
コード例 #3
0
ファイル: DataProvider.cs プロジェクト: ChuckLafferty/bugnet
 public abstract int CreateProjectMailbox(ProjectMailbox mailboxToUpdate);
コード例 #4
0
ファイル: DataProvider.cs プロジェクト: ChuckLafferty/bugnet
 public abstract bool UpdateProjectMailbox(ProjectMailbox mailboxToUpdate);
コード例 #5
0
ファイル: ProjectMailbox.ascx.cs プロジェクト: JackyW83/Test
        /// <summary>
        /// Handles the Click event of the btnAdd control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            var mailbox = new ProjectMailbox
                              {
                                  AssignToDisplayName = string.Empty,
                                  AssignToId = Guid.Empty,
                                  AssignToUserName = IssueAssignedUser.SelectedValue,
                                  IssueTypeId = IssueAssignedType.SelectedValue,
                                  Mailbox = txtMailbox.Text,
                                  ProjectId = ProjectId
                              };

            if (ProjectMailboxManager.SaveOrUpdate(mailbox)) BindMailboxes();
        }