public async Task <ActionResult> Put(int id, MaterialUpsertDto materialUpsertDto)
        {
            await _materialService.UpdateMaterial(id, materialUpsertDto);

            _logger.LogInformation(LogMessages.EntityUpdated);
            return(Ok());
        }
        public async Task <ActionResult> Post(MaterialUpsertDto materialUpsertDto)
        {
            var materialReadDto = await _materialService.CreateMaterialReadDto(materialUpsertDto);

            _logger.LogInformation(LogMessages.EntityCreated);
            return(CreatedAtAction(nameof(Get), new { materialReadDto.Id }, materialReadDto));
        }
Esempio n. 3
0
        public async Task UpdateMaterial(int id, MaterialUpsertDto materialUpsertDto)
        {
            var material = await FindMaterial(id);

            _mapper.Map(materialUpsertDto, material);
            await _unitOfWork.Materials.Update(material);

            await _unitOfWork.Save();
        }
Esempio n. 4
0
        public async Task <MaterialReadDto> CreateMaterialReadDto(MaterialUpsertDto materialUpsertDto)
        {
            var material = _mapper.Map <Material>(materialUpsertDto);
            await _unitOfWork.Materials.Create(material);

            await _unitOfWork.Save();

            return(_mapper.Map <MaterialReadDto>(material));
        }