Beispiel #1
0
        public async Task <IActionResult> Post(WorkItemCategoryRequest request)
        {
            try
            {
                WorkItemCategory workItemCategory = _mapper.Map(request);

                workItemCategory = await _repository.AddAsync(workItemCategory);

                return(CreatedAtAction(nameof(GetById), new { id = workItemCategory.Id }, _mapper.Map(workItemCategory)));
            }

            catch (DataStoreException e)
            {
                _logger.LogError(e.Message, e, request);
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Put(Guid id, WorkItemCategoryRequest request)
        {
            try
            {
                WorkItemCategory workItemCategory = await _repository.GetByIdAsync(id);

                if (workItemCategory == null)
                {
                    return(NotFound());
                }

                _mapper.Map(workItemCategory, request);

                await _repository.UpdateAsync(workItemCategory);

                return(Ok());
            }

            catch (DataStoreException e)
            {
                _logger.LogError(e.Message, e, request);
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }