/// <summary>
        /// Creates a speaker profile
        /// </summary>
        /// <returns>A boolean indicating the success/failure of the process</returns>
        private async Task <bool> createProfile()
        {
            setStatus("Creating Profile...");
            try
            {
                Stopwatch      sw       = Stopwatch.StartNew();
                SpeakerProfile response = await _serviceClient.CreateProfileAsync("en-us");

                sw.Stop();
                setStatus("Profile Created, Elapsed Time: " + sw.Elapsed);
                IsolatedStorageHelper _storageHelper = IsolatedStorageHelper.getInstance();
                _storageHelper.writeValue(MainWindow.SPEAKER_FILENAME, response.VerificationProfileId);
                _speakerId = response.VerificationProfileId;
                return(true);
            }
            catch (ProfileCreationException exception)
            {
                setStatus("Cannot create profile: " + exception.Message);
                return(false);
            }
            catch (Exception gexp)
            {
                setStatus("Error: " + gexp.Message);
                return(false);
            }
        }
Exemple #2
0
    // setup voice properties from speaker profile
    void SwitchSpeaker()
    {
        SpeakerProfile profile = dialogues[dialogueIndex].speaker;

        pitch         = profile.pitch;
        pitchVariance = profile.pitchVariance;
        speed         = profile.speed;
    }
Exemple #3
0
    // setup voice properties from speaker profile
    void SwitchSpeaker()
    {
        SpeakerProfile profile = dialogues[dialogueIndex].speaker;

        pitch         = profile.pitch;
        pitchVariance = profile.pitchVariance;
        speed         = profile.speed;
        nameText.text = "- - " + profile.name + " - -";
    }
Exemple #4
0
        public async Task AssignSpeakerToPresentationAsync(SpeakerProfile speaker, Presentation presentation)
        {
            PresentationSpeaker presentationSpeaker = new PresentationSpeaker
            {
                SpeakerProfile = speaker,
                Presentation   = presentation,
            };

            _planificatorDbContext.PresentationSpeakers.Add(presentationSpeaker);
            await _planificatorDbContext.SaveChangesAsync();
        }
Exemple #5
0
 public CreateSpeakerProfileInput(SpeakerProfile profile)
 {
     Name        = profile.Name;
     PhoneNumber = profile.PhoneNumber;
     Twitter     = profile.Twitter;
     Bio         = profile.Bio;
     ImageUrl    = profile.ImageUrl;
     HomePageUrl = profile.HomePageUrl;
     Email       = profile.Email;
     Tag         = profile.Tag;
 }
Exemple #6
0
 private static SpeakerModel CreateSpeakerModel(SpeakerProfile profile)
 {
     return(new SpeakerModel
     {
         UserId = profile.UserId,
         UserName = profile.UserName,
         Name = profile.Name,
         GravatarUrl = profile.GravatarUrl(),
         NewSpeaker = profile.NewSpeaker,
         SubmittedSessionCount = profile.NumberOfSubmittedSessions
     });
 }
        public async Task AssignSpeakerToPresentation_writes_to_databaseAsync()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            SpeakerProfile speaker = new SpeakerProfile
            {
                SpeakerId = Guid.NewGuid().ToString(),
                FirstName = "Test First Name",
                LastName  = "Test Last Name",
                Email     = "*****@*****.**",
                Bio       = "My test bio",
                Company   = "Test company",
                PhotoPath = "Test Path"
            };

            try
            {
                var options = new DbContextOptionsBuilder <PlanificatorDbContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new PlanificatorDbContext(options))
                {
                    context.Database.EnsureCreated();

                    var presentationService = new PresentationManager(context);
                    var speakerServie       = new SpeakerManager(context);

                    var testData = new PresentationRepositoryTestsData();

                    await speakerServie.AddSpeakerProfileAsync(speaker);

                    await presentationService.AddPresentation(testData.presentationTags);

                    await presentationService.AssignSpeakerToPresentationAsync(speaker, testData.presentation);

                    context.SaveChanges();

                    Assert.Equal(1, context.PresentationSpeakers.Count());
                    Assert.Equal(speaker, context.PresentationSpeakers.Single().SpeakerProfile);
                    Assert.Equal(testData.presentation, context.PresentationSpeakers.Include(p => p.Presentation).Single().Presentation);
                }
            }
            finally
            {
                connection.Close();
            }
        }
 public async Task UpdateSpeakerProfileAsync(SpeakerProfile speaker)
 {
     _planificatorDbContext.SpeakerProfiles.Update(speaker);
     await _planificatorDbContext.SaveChangesAsync();
 }
Exemple #9
0
        public static async Task SeedAsync(this ConferenceContext context, UserManager <User> userStore, CancellationToken cancellationToken = default)
        {
            if (await context.Events.AnyAsync(cancellationToken))
            {
                return;
            }

            // TODO: Use HasGeneratedTsVectorProperty instead of the following when Npgsql 5.0 is released.
            // See https://github.com/npgsql/efcore.pg/issues/1253 for more details.

            await context.Database.ExecuteSqlRawAsync(
                @"CREATE TRIGGER submission_search_vector_update BEFORE INSERT OR UPDATE
                  ON submission FOR EACH ROW EXECUTE PROCEDURE
                  tsvector_update_trigger(search_vector, 'pg_catalog.english', title, description);", cancellationToken);

            await context.Database.ExecuteSqlRawAsync(
                @"CREATE TRIGGER submission_search_vector_update BEFORE INSERT OR UPDATE
                  ON speaker_profile FOR EACH ROW EXECUTE PROCEDURE
                  tsvector_update_trigger(search_vector, 'pg_catalog.english', tag_line, bio);", cancellationToken);

            await context.Database.ExecuteSqlRawAsync(
                @"CREATE TRIGGER submission_search_vector_update BEFORE INSERT OR UPDATE
                  ON ""user"" FOR EACH ROW EXECUTE PROCEDURE
                  tsvector_update_trigger(search_vector, 'pg_catalog.english', email, user_name, given_name, family_name);", cancellationToken);

            var user = new User
            {
                Id         = new Guid("7042C1B5-1295-4A0F-B835-B1B0210FE6E6"),
                UserName   = "******",
                GivenName  = "Kristian",
                FamilyName = "Hellang",
                Email      = "*****@*****.**",
            };

            var result = await userStore.CreateAsync(user);

            if (!result.Succeeded)
            {
                throw new Exception($"Failed to create user:\n{string.Join('\n', result.Errors.Select(x => x.Description))}");
            }

            var ndc = new Event
            {
                Id            = new Guid("f225d953-bf14-449f-8de5-df48500b4ff9"),
                Name          = "NDC Oslo 2020",
                StartTime     = new LocalDateTime(2020, 06, 10, 09, 00),
                EndTime       = new LocalDateTime(2020, 06, 12, 17, 00),
                CfpOpenTime   = new LocalDateTime(2019, 11, 14, 12, 00),
                CfpCloseTime  = new LocalDateTime(2020, 02, 16, 00, 00),
                TimeZoneId    = TzdbDateTimeZoneSource.Default.GetSystemDefaultId(),
                TimeZoneRules = DateTimeZoneProviders.Tzdb.VersionId,
                Venues        =
                {
                    new Venue
                    {
                        Name     = "Oslo Spektrum",
                        Location = "Sonja Henies plass 2, 0185 Oslo",
                        Rooms    =
                        {
                            new Room {
                                Name = "Room 1", Capacity = 250
                            },
                            new Room {
                                Name = "Room 2", Capacity = 250
                            },
                            new Room {
                                Name = "Room 3", Capacity = 250
                            },
                            new Room {
                                Name = "Room 4", Capacity = 250
                            },
                            new Room {
                                Name = "Room 5", Capacity = 450
                            },
                            new Room {
                                Name = "Room 6", Capacity = 400
                            },
                            new Room {
                                Name = "Room 7", Capacity = 450
                            },
                            new Room {
                                Name = "Room 8", Capacity = 300
                            },
                            new Room {
                                Name = "Room 9", Capacity = 150
                            },
                        }
                    },
                },
                SessionFormats =
                {
                    Keynote,
                    Regular,
                    new SessionFormat {
                        Name = "Lightning Talk",Length                      = Period.FromMinutes(10)
                    },
                    new SessionFormat {
                        Name = "Workshop",Length                      = Period.FromMinutes(120)
                    },
                },
                Members =
                {
                    new EventMember {
                        Email = user.Email, Role = EventMemberRole.Admin, User = user
                    },
                },
            };

            var speakerProfile = new SpeakerProfile
            {
                User    = user,
                TagLine = "The most awesome speaker, ever!",
                Bio     = "This is the bio. Ideally it should be longer, but I can't think of something to write.",
            };

            ndc.SpeakerProfiles.Add(speakerProfile);

            ndc.Submissions.Add(new Submission
            {
                Owner       = user,
                Title       = "This is my first talk, hope you like it.",
                Description = "This is the talk description. Short and simple.",
                Formats     = { new SubmissionFormat {
                                    Format = Regular
                                } },
                Speakers = { new Speaker {
                                 Email = user.Email, Profile = speakerProfile
                             } }
            });

            GenerateAgenda(ndc);

            await context.AddAsync(ndc, cancellationToken);

            await context.SaveChangesAsync(cancellationToken);
        }
Exemple #10
0
        public async Task <IActionResult> OnPostConfirmationAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");
            // Get the information about the user from the external login provider
            var info = await _signInManager.GetExternalLoginInfoAsync();

            if (info == null)
            {
                ErrorMessage = "Error loading external login information during confirmation.";
                return(RedirectToPage("./Login", new { ReturnUrl = returnUrl }));
            }

            if (ModelState.IsValid)
            {
                var user = new IdentityUser {
                    UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    //OUR CODE {TRASH}
                    var speakerProfile = new SpeakerProfile
                    {
                        SpeakerId = user.Id,
                        Email     = user.Email,
                        FirstName = "",
                        LastName  = "",
                        PhotoPath = @"\default.png"
                    };
                    await _speakerManager.AddSpeakerProfileAsync(speakerProfile);

                    result = await _userManager.AddLoginAsync(user, info);

                    if (result.Succeeded)
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider);

                        var userId = await _userManager.GetUserIdAsync(user);

                        var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                        code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                        var callbackUrl = Url.Page(
                            "/Account/ConfirmEmail",
                            pageHandler: null,
                            values: new { area = "Identity", userId = userId, code = code },
                            protocol: Request.Scheme);

                        await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                          $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            LoginProvider = info.LoginProvider;
            ReturnUrl     = returnUrl;
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new IdentityUser {
                    UserName = Input.Email, Email = Input.Email,
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var speakerProfile = new SpeakerProfile
                    {
                        SpeakerId = user.Id,
                        Email     = user.Email,
                        FirstName = Input.FirstName,
                        LastName  = Input.LastName,
                        PhotoPath = Path.Combine(_hostingEnvironment.WebRootPath, @"\default.png")
                    };
                    await _speakerManager.AddSpeakerProfileAsync(speakerProfile);

                    await _userManager.AddToRoleAsync(user, "Speaker");

                    _logger.LogInformation("Speaker Profile was created for this user.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
        public ICollection <PresentationTag> MapToPresentationTag(PresentationViewModel presentationViewModel, SpeakerProfile presentationOwner)
        {
            ICollection <string> tags = presentationViewModel.Tags.Split(" ");

            Presentation presentation = new Presentation()
            {
                Title             = presentationViewModel.Title,
                ShortDescription  = presentationViewModel.ShortDescription,
                LongDescription   = presentationViewModel.LongDescription,
                PresentationOwner = presentationOwner
            };

            ICollection <PresentationTag> presentationTags = new List <PresentationTag>();

            foreach (var tagName in tags)
            {
                PresentationTag presentationTag = new PresentationTag()
                {
                    Presentation = presentation,
                    Tag          = new Tag()
                    {
                        TagName = tagName
                    }
                };
                presentationTags.Add(presentationTag);
            }
            return(presentationTags);
        }