コード例 #1
0
        public async Task <IActionResult> OnPostAsync(List <IFormFile> files)
        {
            if (files.Count == 1 && files[0].Length > 0)
            {
                var file = files[0];

                var avatar = new ConferenceDTO.File
                {
                    FileName    = Path.GetFileName(file.FileName),
                    ContentType = "image/png" //file.ContentType
                };

                MemoryStream memoryStream;
                using (var inputStream = file.OpenReadStream())
                {
                    _imageProcessor.GenerateAvatar(inputStream,
                                                   new SixLabors.Primitives.Size(200, 200),
                                                   100,
                                                   out memoryStream);

                    avatar.Content = memoryStream.ToArray();
                    memoryStream.Dispose();
                }

                Attendee.Avatar = avatar;
            }

            await _apiClient.AddAttendeeAsync(Attendee);

            return(RedirectToPage("/Index"));
        }
コード例 #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            await _apiClient.AddAttendeeAsync(Attendee);

            return(RedirectToPage("/Index"));
        }
コード例 #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            var success = await _apiClient.AddAttendeeAsync(Attendee);

            if (!success)
            {
                ModelState.AddModelError("", "There was an issue creating the attendee for this user.");
                return(Page());
            }

            // Re-issue the auth cookie with the new IsAttendee claim
            User.MakeAttendee();
            await HttpContext.SignInAsync(IdentityConstants.ApplicationScheme, User);

            return(RedirectToPage("/Index"));
        }
コード例 #4
0
        public async Task <IActionResult> OnPost()
        {
            // Send the profile to the backend
            // This will throw if there's an error (TODO: Return a result code or something)
            var attendee = await _apiClient.AddAttendeeAsync(new ConferencePlanner.Models.Attendee()
            {
                UserName  = Attendee.UserName,
                FirstName = Attendee.FirstName,
                LastName  = Attendee.LastName
            }, await HttpContext.GetTokenAsync("access_token"));

            // Update our claim with the latest data and update our cookie
            AttendeeClaimMapper.UpdateClaims((ClaimsIdentity)User.Identity, attendee);
            await HttpContext.SignInAsync(User);

            return(RedirectToPage("/Index"));
        }
コード例 #5
0
        public async Task <IActionResult> OnPostAsync()
        {
            await _apiClient.AddAttendeeAsync(Attendee);

            return(RedirectToPage("/Index"));
        }
コード例 #6
0
        public async Task <IActionResult> Post(AttendeeViewModel model)
        {
            await _apiClient.AddAttendeeAsync(model.AsDto());

            return(RedirectToAction("Index"));
        }