public async Task AddEvent(ParticipantEvent participantEvent) { var participations = await this.StateManager.GetStateAsync <Participations>(ActorStateKeyName); var records = participations.Records.FirstOrDefault(i => i.Month == participantEvent.Date.Month && i.Year == participantEvent.Date.Year); if (records == null) { records = CreateMonthYear(participantEvent.Date.Month, participantEvent.Date.Year); participations.Records.Add(records); } records.Events.Add(participantEvent); var validator = new PaticipationsValidator(); var result = await validator.ValidateAsync(participations); if (result.IsValid) { await this.StateManager.SetStateAsync <Participations>(ActorStateKeyName, participations); } else { throw new ApplicationException(result.Errors.First().ErrorMessage); } }
public static HexadoUserResponse ToResponse(this ParticipantEvent entity) { return(new HexadoUserResponse { Id = entity.ParticipantId, UserName = entity.Participant?.UserName }); }
public IActionResult Participate(Guid eventId) { var userId = _userManager.GetUserId(HttpContext.User); var user = _repositoryWrapper.Organizer.GetOrganizerByUserId(userId).User; var currentEvent = _repositoryWrapper.Event.FindEventById(eventId); var participantEvent = new ParticipantEvent { Event = currentEvent, EventId = currentEvent.Id, UserId = user.Id, User = user }; currentEvent.ParticipantEvents.Add(participantEvent); currentEvent.CurrentNumberParticipants++; _repositoryWrapper.Event.Update(currentEvent); _repositoryWrapper.Save(); return(RedirectToAction("Index", "Home")); }
private void TraceNotificationMessage(ParticipantEvent e) { DebugTrace.TxTrace(TraceLevel.Info, e.Enlistment.EnlistmentId, "{0} from {1}", e, Ports.TryGetAddress(e.Participant.ParticipantProxy)); }