Description
A WinForms application with the following as part of a form:
When the "Add" button is clicked, a new entry is added to the ListView
, with data from the TextBox
es and NumericUpDown
above. If an entry with the same "description" and "amount" already exists, then the "quantity" is simply increased by the value given.
Code
The form implements the following interface (partial):
public interface IMainWindow
{
IEnumerable<InvoiceItem> invoiceItems { get; set; }
void addItemToNewInvoice(InvoiceItem item);
}
The view understands domain objects and converts them to and from ListViewItem
s.
There is a Presenter
which gets an instance of the MainWindow
view (implementing the above interface) injected. The presenter then calls the properties and methods of the view.
Question
Where should the logic for determining whether a new item is added to the list or the quantity of an existing item increased, be placed? The View or Presenter? I understand that in the MVP pattern, the view should be as "dumb" as possible. However, is it fine to let the View decide whether to add a completely new row or to increment the quantity in an existing one?