Exemple #1
0
        public async Task <ActionResult> Put(int id, MaterialTypeUpsertDto materialTypeUpsertDto)
        {
            await _materialTypeService.UpdateMaterialType(id, materialTypeUpsertDto);

            _logger.LogInformation(LogMessages.EntityUpdated);
            return(Ok());
        }
Exemple #2
0
        public async Task <ActionResult> Post(MaterialTypeUpsertDto materialTypeUpsertDto)
        {
            var materialTypeReadDto = await _materialTypeService.CreateMaterialTypeReadDto(materialTypeUpsertDto);

            _logger.LogInformation(LogMessages.EntityCreated);
            return(CreatedAtAction(nameof(Get), new { materialTypeReadDto.Id }, materialTypeReadDto));
        }
Exemple #3
0
        public async Task UpdateMaterialType(int id, MaterialTypeUpsertDto materialTypeUpsertDto)
        {
            var materialType = await FindMaterialType(id);

            _mapper.Map(materialTypeUpsertDto, materialType);
            await _unitOfWork.MaterialTypes.Update(materialType);

            await _unitOfWork.Save();
        }
Exemple #4
0
        public async Task <MaterialTypeReadDto> CreateMaterialTypeReadDto(MaterialTypeUpsertDto materialTypeUpsertDto)
        {
            var materialType = _mapper.Map <MaterialType>(materialTypeUpsertDto);
            await _unitOfWork.MaterialTypes.Create(materialType);

            await _unitOfWork.Save();

            return(_mapper.Map <MaterialTypeReadDto>(materialType));
        }