public void Execute(int invoiceId, bool shouldEmail) { var invoice = _database.GetInvoice(invoiceId); if (shouldEmail) { if (invoice.EmailAddress == string.Empty) { throw new EmailAddressIsBlankException(); } _emailer.Email(invoice); } else { if (!_security.IsAdmin()) { throw new UserNotAuthorizedException(); } _writer.Print(invoice); invoice.LastPrintedBy = _security.GetUserName(); _database.Save(); } }
public void Execute(int invoiceId) { var invoice = _database.GetInvoice(invoiceId); if (!_security.IsAdmin()) { throw new UserNotAuthorizedException(); } _writer.Print(invoice); invoice.LastPrintedBy = _security.GetUserName(); _database.Save(); }