Exemple #1
0
        public void EditParticipation(EditParticipationRequest request, string code)
        {
            int IdUser    = getIdUserByLogin(request.Login);
            int IdWebinar = getIdWebinarByCode(code);

            if (!ParticipationExists(IdUser, IdWebinar))
            {
                throw new NotSignedUpToWebinarException("");
            }
            if (_context.Webinars.Where(x => x.Code == code).FirstOrDefault().Date > DateTime.Now)
            {
                throw new NotFinishedWebinarException("");
            }

            UserWebinar participation = _context.UserWebinars.
                                        Where(x => x.IdUser == IdUser).
                                        Where(x => x.IdWebinar == IdWebinar).FirstOrDefault();

            if (participation.Note != null)
            {
                throw new AlreadyNotedWebinarException("");
            }

            participation.Note = (UserWebinar.NoteName)request.Note;
            _context.SaveChanges();
        }
 public IActionResult NoteWebinar(EditParticipationRequest request, string code)
 {
     _context.EditParticipation(request, code);
     return(Ok("Webinar was succesfully noted!"));
 }