Пример #1
0
        public ComponentViewModel Add(ComponentWriteModel model)
        {
            var selectedComponentType = compTypeRepo.GetById(model.ComponentTypeId);
            var component             = new Component(0, selectedComponentType, model.Name, model.Price);
            var entity = repository.Add(component);

            return(ComponentViewModel.FromComponent(entity));
        }
Пример #2
0
        public ComponentViewModel Update(ComponentWriteModel model)
        {
            var component = repository.GetById(model.Id);

            component.Name            = model.Name;
            component.ComponentTypeId = model.ComponentTypeId;
            component.Price           = model.Price;

            var updated = repository.Update(component);

            return(ComponentViewModel.FromComponent(updated));
        }