コード例 #1
0
        public Task AddSuperSubmitterAsync(string microsoftAccount, string firstName, string lastName)
        {
            using (var db = new WebGalleryDbContext())
            {
                var submitter = (from s in db.Submitters
                                 where s.MicrosoftAccount.Equals(microsoftAccount, StringComparison.OrdinalIgnoreCase)
                                 select s).FirstOrDefault();

                // If the super submitter to be added hasn't had a submittership yet, add a new one first in the Submitters table.
                if (submitter == null)
                {
                    submitter = new Submitter
                    {
                        MicrosoftAccount = microsoftAccount,
                        PersonalID       = string.Empty,
                        PersonalIDType   = 1,
                        IsSuperSubmitter = true
                    };
                    db.Submitters.Add(submitter);
                    db.SaveChanges();   // save to database for new submitter id.
                }
                else
                {
                    submitter.IsSuperSubmitter = true;
                }

                // For a new super submitter who has no record in table SubmitterContactDetails,
                // make a new one with the parameters firstName and lastName.
                // If the super submitter already has contact details in the table SubmittersContactDetails, we do nothing here.
                var contactDetail = (from c in db.SubmittersContactDetails
                                     where c.SubmitterID == submitter.SubmitterID
                                     select c).FirstOrDefault();

                if (contactDetail == null)
                {
                    contactDetail = new SubmittersContactDetail
                    {
                        SubmitterID = submitter.SubmitterID,
                        FirstName   = firstName,
                        LastName    = lastName
                    };
                    db.SubmittersContactDetails.Add(contactDetail);
                }

                db.SaveChanges();

                return(Task.FromResult(0));
            }
        }
コード例 #2
0
 private static void SyncContactDetailProperties(SubmittersContactDetail contactDetailInDb,
                                                 SubmittersContactDetail contactDetailInForm)
 {
     contactDetailInDb.FirstName       = contactDetailInForm.FirstName;
     contactDetailInDb.MiddleName      = contactDetailInForm.MiddleName;
     contactDetailInDb.LastName        = contactDetailInForm.LastName;
     contactDetailInDb.Prefix          = contactDetailInForm.Prefix;
     contactDetailInDb.Suffix          = contactDetailInForm.Suffix;
     contactDetailInDb.Title           = contactDetailInForm.Title;
     contactDetailInDb.EMail           = contactDetailInForm.EMail;
     contactDetailInDb.Address1        = contactDetailInForm.Address1;
     contactDetailInDb.Address2        = contactDetailInForm.Address2;
     contactDetailInDb.Address3        = contactDetailInForm.Address3;
     contactDetailInDb.City            = contactDetailInForm.City;
     contactDetailInDb.Country         = contactDetailInForm.Country;
     contactDetailInDb.StateOrProvince = contactDetailInForm.StateOrProvince;
     contactDetailInDb.ZipOrRegionCode = contactDetailInForm.ZipOrRegionCode;
 }
コード例 #3
0
        public Task <Submitter> SaveContactDetailAsync(string email, SubmittersContactDetail contactDetail)
        {
            using (var db = new WebGalleryDbContext())
            {
                var submitter = (from s in db.Submitters
                                 where s.MicrosoftAccount.Equals(email, StringComparison.OrdinalIgnoreCase)
                                 select s).FirstOrDefault();
                if (submitter == null)
                {
                    submitter = new Submitter
                    {
                        MicrosoftAccount = email,
                        PersonalID       = string.Empty,
                        PersonalIDType   = 1,
                        IsSuperSubmitter = null
                    };
                    db.Submitters.Add(submitter);
                    db.SaveChanges(); // save to database for new submitter id.
                }

                var contactDetailInDb = (from c in db.SubmittersContactDetails
                                         where c.SubmitterID == submitter.SubmitterID
                                         select c).FirstOrDefault();
                if (contactDetailInDb == null)
                {
                    contactDetail.SubmitterID = submitter.SubmitterID;
                    db.SubmittersContactDetails.Add(contactDetail);
                }
                else
                {
                    SyncContactDetailProperties(contactDetailInDb, contactDetail);
                }

                db.SaveChanges();

                return(Task.FromResult(submitter));
            }
        }
コード例 #4
0
        private static string BuildBody(Submitter submitter, SubmittersContactDetail contactInfo, Submission submission, string categoryName1, string categoryName2, string frameworkName, IList <SubmissionLocalizedMetaData> metadata, IList <Package> packages, string action, string urlAuthority)
        {
            var body = new StringBuilder();

            body.Append($"SUBMISSION {action}: {submission.Nickname}<br /><br />");

            body.Append(submitter.IsSuperSubmitter() ? string.Empty : $"<a href='https://{urlAuthority}/profiles/{submitter.SubmitterID}'>{contactInfo.FullName}'s contact information</a><br />");
            body.Append($"<a href='https://{urlAuthority}/apps/{submission.SubmissionID}/preview'>Preview this submission</a><br />");
            body.Append($"<a href='https://{urlAuthority}/apps/{submission.SubmissionID}/edit'>Edit this submission</a><br />");

            // logo and screenshots
            body.Append($"<a href='{submission.LogoUrl}'>Logo</a><br />");
            body.Append(string.IsNullOrWhiteSpace(submission.ScreenshotUrl1) ? string.Empty : $"<a href='{submission.ScreenshotUrl1}'>Screenshot 1</a><br />");
            body.Append(string.IsNullOrWhiteSpace(submission.ScreenshotUrl2) ? string.Empty : $"<a href='{submission.ScreenshotUrl2}'>Screenshot 2</a><br />");
            body.Append(string.IsNullOrWhiteSpace(submission.ScreenshotUrl3) ? string.Empty : $"<a href='{submission.ScreenshotUrl3}'>Screenshot 3</a><br />");
            body.Append(string.IsNullOrWhiteSpace(submission.ScreenshotUrl4) ? string.Empty : $"<a href='{submission.ScreenshotUrl4}'>Screenshot 4</a><br />");
            body.Append(string.IsNullOrWhiteSpace(submission.ScreenshotUrl5) ? string.Empty : $"<a href='{submission.ScreenshotUrl5}'>Screenshot 5</a><br />");
            body.Append(string.IsNullOrWhiteSpace(submission.ScreenshotUrl6) ? string.Empty : $"<a href='{submission.ScreenshotUrl6}'>Screenshot 6</a><br />");

            // nickname, version, ...
            body.Append("<table><caption>General</caption>");
            body.Append($"<tr><td class='name'>Nickname</td><td>{submission.Nickname}</td></tr>");
            body.Append($"<tr><td class='name'>Version</td><td>{submission.Version}</td></tr>");
            body.Append($"<tr><td class='name'>Submitting Entity</td><td>{submission.SubmittingEntity}</td></tr>");
            body.Append($"<tr><td class='name'>Submitting Entity URL</td><td>{GenerateLink(submission.SubmittingEntityURL)}</td></tr>");
            body.Append($"<tr><td class='name'>App URL</td><td>{GenerateLink(submission.AppURL)}</td></tr>");
            body.Append($"<tr><td class='name'>Support URL</td><td>{GenerateLink(submission.SupportURL)}</td></tr>");
            body.Append($"<tr><td class='name'>Release Date</td><td>{submission.ReleaseDate.ToShortDateString()}</td></tr>");
            body.Append($"<tr><td class='name'>Primary Category</td><td>{categoryName1}</td></tr>");
            body.Append($"<tr><td class='name'>Secondary Category</td><td>{categoryName2}</td></tr>");
            body.Append($"<tr><td class='name'>Professional Services URL</td><td>{GenerateLink(submission.ProfessionalServicesURL)}</td></tr>");
            body.Append($"<tr><td class='name'>Commercial Product URL</td><td>{GenerateLink(submission.CommercialProductURL)}</td></tr>");
            body.Append($"<tr><td class='name'>Release Notes</td><td>{submission.AdditionalInfo}</td></tr>");
            body.Append("</table>");

            // add metadata
            body.Append("<table><caption>Language Dependent Data</caption>");
            body.Append("<tr><td class='parent-of-table'>");
            foreach (var lang in Language.SupportedLanguages)
            {
                var md = metadata.FirstOrDefault(m => m.Language == lang.Name && m.SubmissionID == submission.SubmissionID);
                if (md != null)
                {
                    body.Append("<table>");
                    body.Append($"<caption>{lang.ShortDisplayName}</caption>");
                    body.Append("<tr>");
                    body.Append($"<td class='name'>Name</td><td dir='{lang.TextDirection}'>{md.Name}</td>");
                    body.Append("</tr>");
                    body.Append("<tr>");
                    body.Append($"<td class='name'>Description</td><td dir='{lang.TextDirection}'>{md.Description}</td>");
                    body.Append("</tr>");
                    body.Append("<tr>");
                    body.Append($"<td class='name'>Brief Description</td><td dir='{lang.TextDirection}'>{md.BriefDescription}</td>");
                    body.Append("</tr>");
                    body.Append("</table>");
                }
            }
            body.Append("</td></tr>");
            body.Append("</table>");

            // add Dependencies
            body.Append("<table><caption>Dependencies</caption>");
            body.Append($"<tr><td class='name'>Framework or Runtime</td><td>{frameworkName}</td></tr>");
            body.Append($"<tr><td class='name'>DatabaseServerIDs</td><td>{submission.DatabaseServerIDs}</td></tr>");
            body.Append($"<tr><td class='name'>WebServerExtensionIDs</td><td>{submission.WebServerExtensionIDs}</td></tr>");
            body.Append("</table>");

            // add packages
            body.Append("<table><caption>Packages</caption>");
            body.Append("<tr><td class='parent-of-table'>");
            foreach (var lang in Language.SupportedLanguages)
            {
                var package = packages.FirstOrDefault(p => p.Language == lang.Name && p.SubmissionID == submission.SubmissionID);
                if (package != null)
                {
                    body.Append("<table>");
                    body.Append($"<caption>{lang.ShortDisplayName}</caption>");
                    body.Append("<tr>");
                    body.Append("<td>");

                    body.Append("<table><caption>x86 Package</caption>");
                    body.Append($"<tr><td class='name'>Package URL</td><td>{GenerateLink(package.PackageURL)}</td></tr>");
                    body.Append($"<tr><td class='name'>Start Page</td><td>{package.StartPage}</td></tr>");
                    body.Append($"<tr><td class='name'>SHA-1 Hash</td><td>{package.SHA1Hash}</td></tr>");
                    body.Append($"<tr><td class='name'>File Size</td><td>{package.FileSize}</td></tr>");
                    body.Append($"<tr><td class='name'>Language</td><td>{package.Language}</td></tr>");
                    body.Append("</table>");

                    body.Append("</td>");
                    body.Append("</tr>");
                    body.Append("</table>");
                }
            }
            body.Append("</td></tr>");
            body.Append("</table>");

            // the end
            body.Append("<hr /><br /><br />");

            return(body.ToString());
        }