Ejemplo n.º 1
0
        public bool SaveComponent(ComponentViewModel component)
        {
            var existingComponent = _componentRepository.Components().FirstOrDefault(a => a.Number == component.Number);

            if (existingComponent != null)
            {
                existingComponent.Number   = component.Number;
                existingComponent.Quantity = component.Quantity;
            }

            var componentEntity = new Component
            {
                Number   = component.Number,
                Quantity = component.Quantity,
                OrderId  = component.OrderId
            };

            return(_componentRepository.Save(existingComponent ?? componentEntity));
        }