protected void OnButtonAddClicked(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(textComment.Buffer.Text) || MessageDialogWorks.RunQuestionDialog("Вы не заполнили комментарий. Продолжить?")) { ServiceClaimStatus newStatus = (ServiceClaimStatus)(enumStatusEditable.SelectedItem ?? UoWGeneric.Root.Status); UoWGeneric.Root.AddHistoryRecord(newStatus, textComment.Buffer.Text, _employeeRepository); } }
public void AddHistoryRecord(ServiceClaimStatus status, string comment, IEmployeeRepository employeeRepository) { if (Status != status) { if (!GetAvailableNextStatusList().Contains(status)) { throw new InvalidOperationException(String.Format("Невозможно перейти из статуса {0} в статус {1}", Status, status)); } Status = status; } ObservableServiceClaimHistory.Add(new ServiceClaimHistory { Date = DateTime.Now, Status = status, Employee = employeeRepository.GetEmployeeForCurrentUser(UoW), Comment = comment, ServiceClaim = this }); }