Ejemplo n.º 1
0
        public async Task <ActionResult <FunModel> > SaveFun(FunModel funModel)
        {
            _context.FunModel.Add(funModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFun", new { id = funModel.FunId }, funModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Put(int artistId, int eventId, [FromBody] UpdateArtistEventTimeRequest request)
        {
            var artist = await _funContext.Artists.FindAsync(artistId);

            if (artist == null)
            {
                return(NotFound("Artist not found"));
            }

            var eventData = await _funContext.Events.FindAsync(eventId);

            if (eventData == null)
            {
                return(NotFound("Event not found"));
            }

            if (eventData.StartDate > request.PerformanceDate || eventData.EndDate < request.PerformanceDate)
            {
                return(BadRequest("Performance date has to be between start and end date"));
            }

            var artistEvent = await _funContext.Artist_Events.FindAsync(artist.IdArtist, eventId);

            artistEvent.PerformanceDate = request.PerformanceDate;

            await _funContext.SaveChangesAsync();

            return(Ok(new UpdateArtistEventTimeResponse
            {
                IdArtist = artist.IdArtist,
                IdEvent = eventData.IdEvent,
                PerformanceDate = request.PerformanceDate
            }));
        }