/// <summary> /// Saves this instance. /// </summary> /// <param name="entity">The issue work report to save.</param> /// <returns></returns> public static bool SaveOrUpdate(IssueWorkReport entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (entity.IssueId <= Globals.NEW_ID) { throw (new ArgumentException("Cannot save issue work report, the issue id is invalid")); } if (!string.IsNullOrEmpty(entity.CommentText)) { entity.CommentId = DataProviderManager.Provider.CreateNewIssueComment( new IssueComment { IssueId = entity.IssueId, Comment = entity.CommentText, CreatorUserName = entity.CreatorUserName, DateCreated = DateTime.Now }); } var tempId = DataProviderManager.Provider.CreateNewIssueWorkReport(entity); if (tempId > Globals.NEW_ID) { entity.Id = tempId; return(true); } return(false); }
/// <summary> /// Handles the Click event of the cmdAddBugTimeEntry control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void AddTimeEntry_Click(object sender, EventArgs e) { if (DurationTextBox.Text.Trim().Length == 0) { return; } var selectedWorkDate = TimeEntryDate.SelectedValue == null ? DateTime.MinValue : (DateTime)TimeEntryDate.SelectedValue; var workDuration = Convert.ToDecimal(DurationTextBox.Text); var workReport = new IssueWorkReport { CommentText = CommentHtmlEditor.Text.Trim(), CreatorUserName = Context.User.Identity.Name, Duration = workDuration, IssueId = IssueId, WorkDate = selectedWorkDate }; IssueWorkReportManager.SaveOrUpdate(workReport); var history = new IssueHistory { IssueId = IssueId, CreatedUserName = Security.GetUserName(), DateChanged = DateTime.Now, FieldChanged = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "TimeLogged", "Time Logged"), OldValue = string.Empty, NewValue = DurationTextBox.Text.Trim(), TriggerLastUpdateChange = true }; IssueHistoryManager.SaveOrUpdate(history); var changes = new List <IssueHistory> { history }; IssueNotificationManager.SendIssueNotifications(IssueId, changes); CommentHtmlEditor.Text = string.Empty; DurationTextBox.Text = string.Empty; BindTimeEntries(); }
// Issue Work Reports public abstract int CreateNewIssueWorkReport(IssueWorkReport workReportToCreate);