/// <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; }
/// <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); } }
public abstract int CreateProjectMailbox(ProjectMailbox mailboxToUpdate);
public abstract bool UpdateProjectMailbox(ProjectMailbox mailboxToUpdate);
/// <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(); }