Ejemplo n.º 1
0
        public async Task <DbAnswer> ChangeAsync(int idArt, int idEv, NewDateDto newDate)
        {
            var artist = await context.Atist.FindAsync(idArt);

            if (artist == null)
            {
                return(DbAnswer.ArtistNotFound);
            }

            var evente = await context.Event.FindAsync(idEv);

            if (evente == null)
            {
                return(DbAnswer.EventNotFound);
            }

            var artev = await context
                        .AtistEvent
                        .FirstOrDefaultAsync(e => e.IdEvent == idEv && e.IdArtist == idArt);

            if (artev == null)
            {
                return(DbAnswer.NotFound);
            }

            if (evente.StartDate >= newDate.NEwDate && newDate.NEwDate <= evente.EndDate)
            {
                return(DbAnswer.NotSuitableDate);
            }
            else
            {
                artev.PerfomanceDate = newDate.NEwDate;
                await context.SaveChangesAsync();
            }

            return(DbAnswer.OK);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Change([FromRoute] int idArt, [FromRoute] int idEv, [FromBody] NewDateDto newDateDto)
        {
            var answer = await repository.ChangeAsync(idArt, idEv, newDateDto);

            switch (answer)
            {
            case Enums.DbAnswer.NotSuitableDate:
                return(BadRequest("Date is not suitable"));

                break;

            case Enums.DbAnswer.OK:
                return(Ok("Changed"));

                break;

            default:
                return(NotFound("Artist or event not found! or its relatioship"));
            }

            return(Ok());
        }