public IActionResult Put(int id, [FromBody] TheatricalEvent theatricalEvent)
 {
     if (ModelState.IsValid)
     {
         db.Update(theatricalEvent);
         db.SaveChanges();
         return(Ok(theatricalEvent));
     }
     return(BadRequest(ModelState));
 }
 public IActionResult Post([FromBody] TheatricalEvent theatricalEvent)
 {
     if (ModelState.IsValid)
     {
         db.TheatricalEvents.Add(theatricalEvent);
         db.SaveChanges();
         return(Ok(theatricalEvent));
     }
     return(BadRequest(ModelState));
 }
        public IActionResult Delete(int id)
        {
            TheatricalEvent theatricalEvent = db.TheatricalEvents.FirstOrDefault(x => x.Id == id);

            if (theatricalEvent != null)
            {
                db.TheatricalEvents.Remove(theatricalEvent);
                db.SaveChanges();
            }
            return(Ok(theatricalEvent));
        }
        public ScheduledEventDTO Get(int id)
        {
            TheatricalEvent   theatricalEvent   = db.TheatricalEvents.FirstOrDefault(x => x.Id == id);
            ScheduledEventDTO scheduledEventDTO = new ScheduledEventDTO();

            scheduledEventDTO.TheatricalEvent = theatricalEvent;
            var scheduledEvents = db.ScheduledEvents.Where(x => x.TheatricalEventId == id);

            scheduledEventDTO.Dates = scheduledEvents.Select(se => se.Date).ToArray();
            return(scheduledEventDTO);
        }
        public ScheduledEventDTO Get(int id)
        {
            TheatricalEvent theatricalEvent = db.TheatricalEvents.Find(id);

            ScheduledEventDTO scheduledEventDto = new ScheduledEventDTO()
            {
                /*TheatricalEventId = theatricalEvent.Id,
                 * Name = theatricalEvent.Name,
                 * Image = theatricalEvent.Image*/
                TheatricalEvent = theatricalEvent
            };

            IQueryable <ScheduledEvent> scheduledEvents = db.ScheduledEvents.Where(x => x.TheatricalEventId == id);

            if (scheduledEvents.Any())
            {
                scheduledEventDto.Dates = scheduledEvents.Select(x => x.Date).ToArray();
            }

            return(scheduledEventDto);
        }
        public TheatricalEvent Get(int id)
        {
            TheatricalEvent theatricalEvent = db.TheatricalEvents.FirstOrDefault(x => x.Id == id);

            return(theatricalEvent);
        }