Beispiel #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            try
            {
                await repo.SaveEventAsync(Event);
            }
            catch (DbUpdateConcurrencyException)
            {
                Models.Event x = await repo.GetEventAsync(Event.Id);

                if (x == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToPage("EventIndex", new { teamId = Event?.TeamId }));
        }
Beispiel #2
0
        private async Task LoadContextAsync(int?teamId, int?eventId)
        {
            Me      = meProvider.Me;
            MyTeams = Me.Membership.Select(x => x.Team).ToList() ?? new List <Team>();

            Event = await eventRepo.GetEventAsync(eventId);

            if (Event == null)
            {
                Team  = meProvider.GetTeam(teamId);
                Event = Team?.Event.OrderBy(x => x.Date).FirstOrDefault(x => x.Date > DateTime.Now);
            }
            else
            {
                Team = meProvider.GetTeam(Event.TeamId);
                if (Team?.Id != Event.TeamId)
                {
                    Event = null;
                }
            }
            Membership    = Me.Membership.FirstOrDefault(x => x.TeamId == Team?.Id);
            Participation = Event?.Participation.FirstOrDefault(x => x.PersonId == Me.Id);

            NextEvents = Team.Event
                         .OrderBy(x => x.Date)
                         .Where(x => !x.Special && x.Date > DateTime.Now.AddHours(-1) && x.Id != Event?.Id)
                         .Take(5)
                         .ToList();
            SpecialEvents = Team.Event
                            .OrderBy(x => x.Date)
                            .Where(x => x.Special && x.Date > DateTime.Now.AddHours(-1) && x.Id != Event?.Id)
                            .ToList();

            Posts = Team.Post.TakeLast(50).OrderByDescending(x => x.Id).ToList();
            if (Posts.Count > 0 && Posts[0].PersonId == Me?.Id)
            {
                MyLastPost = Posts[0];
            }
        }
Beispiel #3
0
        //public async Task SendInvitationMailAsync(Membership membership)
        //{
        //    //throw new NotImplementedException();
        //}

        public async Task SendParticipatonMailAsync(Participation participation)
        {
            Models.Event Event = await eventRepo.GetEventAsync(participation.EventId);

            List <string> emails = participation.Event.Team.GetEmailsButPersons(new List <int>()
            {
                participation.PersonId, participation.ByPersonId
            });

            if (emails.Count > 0)
            {
                string subject = "Csapatmozgás - " + participation.Event.Team.Name + " - " + participation.Event.Description;
                string message = "<p>" + ((participation.PersonId != participation.ByPersonId) ? participationTextProvider.GetByPersonDisplayName(participation) + " szerint " :"")
                                 + participationTextProvider.GetPersonDisplayName(participation) + " csapattársad "
                                 + (participation.Participate ?? false ? "jönni fog :)" : "nem fog jönni :(</p>")
                                 + "<p>Eddig " + Event.Participation.Count(x => x.Participate ?? false).ToString() + " csapattársad jelentkezett.</p>"
                                 + "<a href=\"https://megyek.eu/?eventId=" + participation.Event.Id.ToString() + "\">megyek.eu</a>";
                await emailsSender.SendEmailsAsync(emails, subject, message);
            }
            if (participation.PersonId != participation.ByPersonId)
            {
                Membership membership = participation.Event.Team.Membership.FirstOrDefault(x => x.PersonId == participation.PersonId);
                if (membership?.Mail ?? false)
                {
                    emails = new List <string> {
                        participation.Person.UserName
                    };
                    string subject = "Csapatmozgás - " + participation.Event.Team.Name + " - " + participation.Event.Description;
                    string message = "<p>" + ((participation.PersonId != participation.ByPersonId) ? participationTextProvider.GetByPersonDisplayName(participation) + " szerint " : "")
                                     + (participation.Participate ?? false ? "jönni fogsz :)" : "nem fogsz jönni :(</p>")
                                     + "<p>Eddig " + Event.Participation.Count(x => x.Participate ?? false).ToString() + " csapattársad jelentkezett.</p>"
                                     + "<a href=\"https://megyek.eu/?eventId=" + participation.Event.Id.ToString() + "\">megyek.eu</a>";
                    await emailsSender.SendEmailsAsync(emails, subject, message);
                }
            }
        }