Example #1
0
        public async Task <IActionResult> Update(
            [FromRoute] Guid culturalEventId,
            [FromBody] CulturalEventViewModel viewModel)
        {
            try
            {
                var culturalEvent = _mapper.Map <CulturalEvent>(viewModel);
                culturalEvent.Id = culturalEventId;
                await _culturalEventUseCases.Update(culturalEvent, GetUserId());

                return(NoContent());
            }
            catch (NotFoundException e)
            {
                return(NotFound(e.Message));
            }
        }
Example #2
0
        public async Task <IActionResult> Add(
            [FromQuery] Guid subdivisionId,
            [FromBody] CulturalEventViewModel viewModel)
        {
            try
            {
                var culturalEventToAdd = _mapper.Map <CulturalEvent>(viewModel);
                culturalEventToAdd.Subdivision = new Subdivision {
                    Id = subdivisionId
                };
                var culturalEvent = await _culturalEventUseCases.Add(culturalEventToAdd, GetUserId());

                return(Ok(new { culturalEvent.Id }));
            }
            catch (BadRequestException e)
            {
                return(BadRequest(e.Message));
            }
        }