public async Task HandleAsync(AttendEvent command) { var attendableEvent = await _attendableEventsRepository.GetAsync(command.Id); if (attendableEvent is null) { throw new AttendableEventNotFoundException(command.Id); } var participant = await _participantsRepository .GetAsync(attendableEvent.ConferenceId, command.ParticipantId); if (participant is null) { throw new ParticipantNotFoundException(attendableEvent.ConferenceId, command.ParticipantId); } attendableEvent.Attend(participant); await _participantsRepository.UpdateAsync(participant); await _attendableEventsRepository.UpdateAsync(attendableEvent); }
public async Task <IActionResult> Put(long id, [FromBody] Models.Participants model) { if (id == 0) { return(BadRequest("id is required field")); } String Error = ValidateInput(model); if (!String.IsNullOrEmpty(Error)) { return(BadRequest(Error)); } var entity = await repository.FindAsync(id); if (entity == null) { return(NotFound()); } entity.id = id; entity.combine_id = model.combine_id; entity.user_id = model.user_id; entity.participant_type = model.participant_type; entity.band_id = model.band_id; entity.rfid = model.rfid; entity.preemail = model.preemail; entity.postemail = model.postemail; entity.created = model.created; entity.modified = DateTime.Now; await repository.UpdateAsync(entity); return(Ok("data has been modified")); }