예제 #1
0
 private void ValidateDuplicatedProduct(OutputItem item)
 {
     if (ExistsProduct(item.Product) is true)
     {
         throw ExceptionsFactory.FactoryDomainException(Messages.ProductFound);
     }
 }
예제 #2
0
 private void ValidateDuplicatedItem(OutputItem item)
 {
     if (ExistsItem(item) is true)
     {
         throw ExceptionsFactory.FactoryDomainException(Messages.ItemFound);
     }
 }
예제 #3
0
 private void ValidateIfNotExistsItem(OutputItem item)
 {
     if (ExistsItem(item) is false)
     {
         throw ExceptionsFactory.FactoryNotFoundException <Output>(item.Id);
     }
 }
예제 #4
0
        public void AddItem(OutputItem item)
        {
            ValidateDuplicatedItem(item);
            ValidateDuplicatedProduct(item);

            _items.Add(item);

            CalculateTotalValue();
        }
예제 #5
0
        public void RemoveItem(OutputItem item)
        {
            ValidateOpenState();

            ValidateIfNotExistsItem(item);

            _items.Remove(item);

            CalculateTotalValue();
        }
예제 #6
0
        public void UpdateItem(OutputItem item)
        {
            ValidateDuplicatedItem(item);
            ValidateDuplicatedProduct(item);

            OutputItem existItem = FindItemById(item.Id);

            existItem.Update(item.Amount, item.Value, item.Product);

            CalculateTotalValue();
        }
예제 #7
0
 private bool ExistsItem(OutputItem item)
 => Items.Any(x => x.Id == item.Id);