예제 #1
0
        public async Task SendRemindersAsync(List <string> emailList, Occurrence occurrence)
        {
            Opportunity opportunity = occurrence.Opportunity;
            //            string messageText = "Hey There! This is a reminder for your upcoming volunteer gig. " +
            //                         "Please reply to this email if you can no longer make the event.";

            string messageText = "Volunteers: " + String.Join("\n", emailList);

            SendGridMessage sendGridMessage = new SendGridMessage()
            {
                From             = new EmailAddress(FromEmail, "Volly Team"),
                Subject          = "Volly Reminder: " + opportunity.Name,
                TemplateId       = "d-70aba37e40834a89b8afe3a1a9567bcd",
                HtmlContent      = messageText,
                PlainTextContent = messageText
            };

            DateTime startTime = VollyConstants.ConvertFromUtc(occurrence.StartTime);
            DateTime endTime   = VollyConstants.ConvertFromUtc(occurrence.EndTime);

            sendGridMessage.AddSubstitution(":start", startTime.ToShortDateString() + " " + startTime.ToShortTimeString());
            sendGridMessage.AddSubstitution(":end", endTime.ToShortDateString() + " " + endTime.ToShortTimeString());
            sendGridMessage.AddSubstitution(":description", opportunity.Description);
            sendGridMessage.AddSubstitution(":address", opportunity.Address);
            sendGridMessage.AddSubstitution(":name", opportunity.Name);
            sendGridMessage.AddSubstitution(":image", opportunity.ImageUrl);

            var client = new SendGridClient(SendgridApiKey);

            sendGridMessage.AddTo(VollyConstants.AliceEmail);

            Response response = await client.SendEmailAsync(sendGridMessage);
        }
예제 #2
0
        public void CreateOrUpdate(ApplicationDbContext context, string userId)
        {
            VolunteerHours volunteerHours = context.VolunteerHours.Find(Id);
            DateTime       dateTime       = VollyConstants.ConvertToUtc(DateTime);

            if (volunteerHours != null)
            {
                volunteerHours.Hours            = Hours;
                volunteerHours.DateTime         = dateTime;
                volunteerHours.OpportunityName  = OpportunityName;
                volunteerHours.OrganizationName = OrganizationName;
            }
            else
            {
                VolunteerHours newVolunteerHours = new VolunteerHours()
                {
                    OpportunityName  = OpportunityName,
                    OrganizationName = OrganizationName,
                    DateTime         = dateTime,
                    Hours            = Hours,
                    UserId           = userId
                };

                context.Add(newVolunteerHours);
            }

            context.SaveChanges();
        }
예제 #3
0
 public static Func <Occurrence, Occurrence> ConvertToUtc()
 {
     return(delegate(Occurrence occurrence)
     {
         occurrence.StartTime = VollyConstants.ConvertToUtc(occurrence.StartTime);
         occurrence.EndTime = VollyConstants.ConvertToUtc(occurrence.EndTime);
         occurrence.ApplicationDeadline = VollyConstants.ConvertToUtc(occurrence.ApplicationDeadline);
         return occurrence;
     });
 }
예제 #4
0
 public static OccurrenceView FromOccurrence(Occurrence occurrence)
 {
     return(new OccurrenceView
     {
         Id = occurrence.Id,
         StartTime = VollyConstants.ConvertFromUtc(occurrence.StartTime),
         EndTime = VollyConstants.ConvertFromUtc(occurrence.EndTime),
         ApplicationDeadline = VollyConstants.ConvertFromUtc(occurrence.ApplicationDeadline),
         Openings = occurrence.Openings - occurrence.Applications.Count
     });
 }
예제 #5
0
 public static VolunteerHoursModel FromVolunteerHours(VolunteerHours volunteerHours)
 {
     return(new VolunteerHoursModel()
     {
         Id = volunteerHours.Id,
         User = volunteerHours.User.Email,
         UserId = volunteerHours.User.Id,
         DateTime = VollyConstants.ConvertFromUtc(volunteerHours.DateTime),
         Hours = volunteerHours.Hours,
         OrganizationName = volunteerHours.OrganizationName,
         OpportunityName = volunteerHours.OpportunityName
     });
 }
예제 #6
0
 public static VolunteerHoursCSVModel FromVolunteerHours(VolunteerHours volunteerHours)
 {
     return(new VolunteerHoursCSVModel()
     {
         Company = volunteerHours.User?.Company?.Name,
         CompanyCode = volunteerHours.User?.Company?.CompanyCode,
         User = volunteerHours.User.Email,
         OrganizationName = volunteerHours.OrganizationName,
         OpportunityName = volunteerHours.OpportunityName,
         DateTime = VollyConstants.ConvertFromUtc(volunteerHours.DateTime),
         Hours = volunteerHours.Hours
     });
 }
예제 #7
0
        public static ApplicationView FromApplication(Application application)
        {
            List <OccurrenceView> occurrenceViews = application.Occurrences
                                                    .Select(ao => ao.Occurrence)
                                                    .Select(OccurrenceView.FromOccurrence)
                                                    .ToList();

            return(new ApplicationView()
            {
                Id = application.Id,
                OpportunityId = application.Opportunity.Id,
                OpportunityName = application.Opportunity.Name,
                OpportunityImageUrl = application.Opportunity.ImageUrl,
                OpportunityAddress = application.Opportunity.Address,
                OpportunityDescription = application.Opportunity.Description,
                Name = application.Name,
                Email = application.Email,
                PhoneNumber = application.PhoneNumber,
                Message = application.Message,
                DateTime = VollyConstants.ConvertFromUtc(application.DateTime),
                OccurrenceViews = occurrenceViews,
                UserName = application.User?.UserName
            });
        }