Exemplo n.º 1
0
        public async Task <EquipmentDto> GetEquipmentById(int id)
        {
            var request = await _equipment.GetAsync(id);//_uow.Equipment.GetAsync(id);

            if (request == null)
            {
                throw await _helper.GetExceptionAsync("Equipment entry does not exist");
            }
            return(_mapper.Map <Equipment, EquipmentDto>(request));
        }
        public async Task <bool> Handle(CreateActionTypeCommand request, CancellationToken cancellationToken)
        {
            var equipment = await _equipmentRepository.GetAsync(request.EquipmentId);

            if (equipment == null)
            {
                return(false);
            }

            _logger.LogInformation("----- Adding action type to the Equipment: {EquipmentId}", request.EquipmentId);
            equipment.AddActionType(request.FirstOccurenceDateTime, request.TaskFrequencyId, request.TaskTypeId);

            return(await _equipmentRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken));
        }