public static ProjectFollowEntity Create(IProjectFollowData src) { var id = GenerateRowKey(src.ProjectId, src.UserId); var result = new ProjectFollowEntity { PartitionKey = GeneratePartitionKey(), RowKey = id, Id = id, FullName = src.FullName, UserId = src.UserId, ProjectId = src.ProjectId, UserAgent = src.UserAgent }; return(result); }
public static string GenerateCompetitionMessage(IProjectData project, IProjectFollowData follower) { var model = new Competition { FirstName = GetFirstNameFromFullName(follower.FullName), ProjectId = project.Id, ProjectStatus = Status.Registration.ToString(), ProjectAuthorName = project.AuthorFullName, ProjectCompetitionDeadline = project.CompetitionRegistrationDeadline, ProjectCreatedDate = project.Created, ProjectDescription = project.Overview, ProjectFirstPrize = project.BudgetFirstPlace, ProjectName = project.Name, ProjectSecondPrize = project.BudgetSecondPlace ?? 0 }; var messageData = new CompetitionEmailMessageData { Subject = "Competition", Sender = EmailSender, Model = model }; var data = new CompetitionEmailData { EmailAddress = follower.UserId, MessageData = messageData }; var competitionEmail = new CompetitionEmail { Data = data }; var message = JsonConvert.SerializeObject(competitionEmail); return(MailType + message); }
public static string GenerateImplementationMessage(IProjectData project, IProjectFollowData follower, string templateType) { var model = new Implementation { FirstName = GetFirstNameFromFullName(follower.FullName), ProjectId = project.Id, ProjectStatus = Status.Implementation.ToString(), ProjectAuthorName = project.AuthorFullName, ProjectImplementationDeadline = project.ImplementationDeadline, ProjectCreatedDate = project.Created, ProjectDescription = project.Description, ProjectFirstPrize = project.BudgetFirstPlace, ProjectName = project.Name, ProjectSecondPrize = project.BudgetSecondPlace ?? 0 }; var messageData = new ImplementationEmailMessageData { Subject = templateType, Sender = "Competition Platform", Model = model }; var data = new ImplementationEmailData { EmailAddress = follower.UserId, MessageData = messageData }; var implementationEmail = new ImplementationEmail { Data = data }; var message = JsonConvert.SerializeObject(implementationEmail); return(MailType + message); }
public static string GenerateArchiveMessage(IProjectData project, IProjectFollowData follower, int participantsCount, int resultsCount, IEnumerable <IWinnerData> winners) { var duration = (project.VotingDeadline - project.Created).Days; var firstPlaceWinnerName = ""; var firstPlaceWinnerId = ""; var firstPlaceWinnerScore = 0; var firstPlaceWinnerVotes = 0; var secondPlaceWinnerName = ""; var secondPlaceWinnerId = ""; var secondPlaceWinnerScore = 0; var secondPlaceWinnerVotes = 0; var thirdPlaceWinnerName = ""; var thirdPlaceWinnerId = ""; var thirdPlaceWinnerScore = 0; var thirdPlaceWinnerVotes = 0; var fourthPlaceWinnerName = ""; var fourthPlaceWinnerId = ""; var fourthPlaceWinnerScore = 0; var fourthPlaceWinnerVotes = 0; var winnersData = winners as IWinnerData[] ?? winners.ToArray(); for (int i = 1; i <= winnersData.Count(); i++) { if (i == 1) { firstPlaceWinnerName = winnersData[0].FullName; firstPlaceWinnerId = winnersData[0].WinnerId; firstPlaceWinnerScore = winnersData[0].Score; firstPlaceWinnerVotes = winnersData[0].Votes; } if (i == 2) { secondPlaceWinnerName = winnersData[1].FullName; secondPlaceWinnerId = winnersData[1].WinnerId; secondPlaceWinnerScore = winnersData[1].Score; secondPlaceWinnerVotes = winnersData[1].Votes; } if (i == 3) { thirdPlaceWinnerName = winnersData[2].FullName; thirdPlaceWinnerId = winnersData[2].WinnerId; thirdPlaceWinnerScore = winnersData[2].Score; thirdPlaceWinnerVotes = winnersData[2].Votes; } if (i == 4) { fourthPlaceWinnerName = winnersData[3].FullName; fourthPlaceWinnerId = winnersData[3].WinnerId; fourthPlaceWinnerScore = winnersData[3].Score; fourthPlaceWinnerVotes = winnersData[3].Votes; } } var model = new Archive { FirstName = GetFirstNameFromFullName(follower.FullName), ProjectId = project.Id, ProjectCreatedDate = project.Created, ProjectAuthorName = project.AuthorFullName, ProjectName = project.Name, ProjectStatus = Status.Archive.ToString(), ProjectDescription = project.Overview, ProjectFirstPrize = project.BudgetFirstPlace, ProjectSecondPrize = project.BudgetSecondPlace ?? 0, ParticipantCount = participantsCount, ResultCount = resultsCount, WinnerCount = winnersData.Count(), Duration = duration, FirstPlaceWinnerName = firstPlaceWinnerName, FirstPlaceWinnerId = firstPlaceWinnerId, FirstPlaceWinnerScore = firstPlaceWinnerScore, FirstPlaceWinnerVotes = firstPlaceWinnerVotes, SecondPlaceWinnerName = secondPlaceWinnerName, SecondPlaceWinnerId = secondPlaceWinnerId, SecondPlaceWinnerScore = secondPlaceWinnerScore, SecondPlaceWinnerVotes = secondPlaceWinnerVotes, ThirdPlaceWinnerName = thirdPlaceWinnerName, ThirdPlaceWinnerId = thirdPlaceWinnerId, ThirdPlaceWinnerScore = thirdPlaceWinnerScore, ThirdPlaceWinnerVotes = thirdPlaceWinnerVotes, FourthPlaceWinnerName = fourthPlaceWinnerName, FourthPlaceWinnerId = fourthPlaceWinnerId, FourthPlaceWinnerScore = fourthPlaceWinnerScore, FourthPlaceWinnerVotes = fourthPlaceWinnerVotes }; var messageData = new ArchiveEmailMessageData { Subject = "Archive", Sender = EmailSender, Model = model }; var data = new ArchiveEmailData { EmailAddress = follower.UserId, MessageData = messageData }; var archiveEmail = new ArchiveEmail { Data = data }; var message = JsonConvert.SerializeObject(archiveEmail); return(MailType + message); }
public async Task SaveAsync(IProjectFollowData projectFollowData) { var newEntity = ProjectFollowEntity.Create(projectFollowData); await _projectFollowTableStorage.InsertAsync(newEntity); }