public async Task <Component> Add(AddComponentCommand command)
        {
            var component = new Component
            {
                Id     = Guid.NewGuid(),
                Name   = command.Name,
                Amount = command.Amount
            };

            await _componentRepository.Add(component);

            return(component);
        }
Ejemplo n.º 2
0
        public async Task <Component> Add(AddComponentCommand command)
        {
            var component = new Component
            {
                Id          = Guid.NewGuid(),
                Name        = command.Name,
                Brand       = command.Brand,
                Description = command.Description,
                ImagePath   = command.ImagePath,
                Price       = command.Price,
                Amount      = command.Amount,
                Type        = command.Type
            };

            await _componentRepository.Add(component);

            return(component);
        }
Ejemplo n.º 3
0
        private ComponentWrapper CreateNewComponent() //calls the add method in the repository to insert new equipment and return it
        {
            var component = new ComponentWrapper(new Model.Component());

            //when property in equipment changes, and it has errors, disable the create button
            component.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(Component.HasErrors))
                {
                    ((DelegateCommand)CreateComponentCommand).RaiseCanExecuteChanged();
                }
            };
            ((DelegateCommand)CreateComponentCommand).RaiseCanExecuteChanged();

            //default values
            component.ComponentType         = "";
            component.ComponentSupplyNumber = "";
            component.ComponentSerialNumber = "";

            _componentRepository.Add(component.Model); //context is aware of the equipment to add
            return(component);
        }
Ejemplo n.º 4
0
 public void AddComponent(params Component[] Components)
 {
     _componentRepository.Add(Components);
 }