Example #1
0
        public IActionResult UpdatePerform(DateTime date, int eventId, int artistId)
        {
            var ev = _context.Events.Where(d => d.IdEvent == eventId).First();

            if (ev == null)
            {
                return(BadRequest());
            }

            if (ev.StastDate < DateTime.Now || date < ev.StastDate || date > ev.EndDate)
            {
                return(BadRequest());
            }

            var perform = new Artist_Event
            {
                IdArtist        = artistId,
                IdEvent         = eventId,
                PerformanceDate = date
            };

            _context.Attach(perform);
            _context.Entry(perform).Property("PerformanceDate").IsModified = true;
            _context.SaveChanges();
            return(Ok(perform));
        }
Example #2
0
 public IActionResult UpdateEvt(int idArt, int idevt, Artist_Event art)
 {
     try
     {
         _context.EventChange(idArt, idevt, art);
         return(Ok());
     }
     catch (Event404 exc)
     {
         return(NotFound(exc));
     }catch (EventStertedExc exc)
     {
         return(BadRequest(exc));
     }
     return(Ok());
 }
Example #3
0
        public void EventChange(int idart, int idevt, Artist_Event art)
        {
            var dt = DateTime.Now;


            var evt = _context.Events.Where(p => p.IdEvent == idevt).SingleOrDefault();

            if (evt == null)
            {
                throw new Event404($"event with id ={idevt} not exists");
            }
            if (evt.StartDate.CompareTo(dt) < 0)
            {
                throw new EventStertedExc($"event started already");
            }
            _context.Attach(art);
            _context.Entry(art).State = EntityState.Modified;
            _context.SaveChanges();
        }
Example #4
0
 public IActionResult ModifyPerformanceTime(Artist_Event artist_Event)
 {
     try
     {
         _context.ModifyPerformanceTime(artist_Event);
         return(NoContent());
     }
     catch (EventDoesNotExistsException exc)
     {
         return(NotFound(exc.Message));
     }
     catch (EventHasAlreadyStartedException exc)
     {
         return(BadRequest(exc.Message));
     }
     catch (PerformanceDateIsNotWithinEventTime exc)
     {
         return(BadRequest(exc.Message));
     }
 }
Example #5
0
        public void ModifyPerformanceTime(Artist_Event artist_Event)
        {
            var ev = _context.Events.Where(e => e.IdEvent == artist_Event.IdEvent).SingleOrDefault();

            if (ev == null)
            {
                throw new EventDoesNotExistsException($"Event with an id={artist_Event.IdEvent} does not exists");
            }
            if (ev.StartDate.CompareTo(DateTime.Now) < 0)
            {
                throw new EventHasAlreadyStartedException($"Event with an id={artist_Event.IdEvent} has already started");
            }
            if (!(ev.StartDate.CompareTo(artist_Event.PerformanceDate) < 0 && artist_Event.PerformanceDate.CompareTo(ev.EndDate) < 0))
            {
                throw new PerformanceDateIsNotWithinEventTime("Performance date is not within event time");
            }
            _context.Attach(artist_Event);
            _context.Entry(artist_Event).State = EntityState.Modified;
            _context.SaveChanges();
        }