Ejemplo n.º 1
0
        public IActionResult Post([FromBody] EventDetail EventDetail)
        {
            if (EventDetail == null)
            {
                return(BadRequest("EventDetail is null."));
            }

            _EventDetailRepository.Add(EventDetail);
            return(CreatedAtRoute(
                       "EventDetailGet",
                       new { Id = EventDetail.EventDetailID },
                       EventDetail));
        }
Ejemplo n.º 2
0
        public async Task <EventDetailResponse> AddAsync(EventDetail eventDetailToAdd)
        {
            var existingEvent = await _eventRepository.FindByIdAsync(eventDetailToAdd.EventId);

            try
            {
                if (existingEvent == null)
                {
                    return(new EventDetailResponse("Invalid Event."));
                }

                await _eventDetailRepository.Add(eventDetailToAdd);

                await _unitOfWork.CompleteAsync();

                return(new EventDetailResponse(eventDetailToAdd));
            }
            catch (Exception ex)
            {
                return(new EventDetailResponse($"An error occured when saving Event Details: {ex.Message}"));
            }
        }