Ejemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync(string userId, string code)
        {
            if (userId == null || code == null)
            {
                return(RedirectToPage("/Index"));
            }

            var user = await _userManager.FindByIdAsync(userId);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{userId}'."));
            }
            foreach (Colour colour in await _filtersServices.GetColourAsync())
            {
                ColourTaste colourTaste = new ColourTaste();
                colourTaste.ColourId  = colour.Id;
                colourTaste.AppUserId = userId;
                colourTaste.Score     = 0;
                await _tasteServices.CreateColourTasteAsync(colourTaste);
            }
            foreach (Source source in await _filtersServices.GetSourceAsync())
            {
                SourceTaste sourceTaste = new SourceTaste();
                sourceTaste.SourceId  = source.Id;
                sourceTaste.AppUserId = userId;
                sourceTaste.Score     = 0;
                await _tasteServices.CreateSourceTasteAsync(sourceTaste);
            }
            foreach (Sweetnes sweetnes in await _filtersServices.GetSweetnesAsync())
            {
                SweetnessTaste sweetnessTaste = new SweetnessTaste();
                sweetnessTaste.SweetnesId = sweetnes.Id;
                sweetnessTaste.AppUserId  = userId;
                sweetnessTaste.Score      = 0;
                await _tasteServices.CreateSweetnessTasteAsync(sweetnessTaste);
            }

            WineList wineList = new WineList
            {
                AppUserId   = userId,
                ListDate    = DateTime.Now,
                ListName    = "Favoritos",
                Description = "Vinos favoritos"
            };

            await _wineListsServices.CreateWineListAsync(wineList);

            code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
            var result = await _userManager.ConfirmEmailAsync(user, code);

            StatusMessage = result.Succeeded ? "Gracias por registrarte en VinoNet." : "/*No te has podido registrar correctamente.*/";
            return(Page());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Survey()
        {
            List <SourceTaste> sourcetaste = await _tastesServices.GetSourceTastesAsync();

            List <ColourTaste> colourtaste = await _tastesServices.GetColourTastesAsync();

            List <SweetnessTaste> sweetnesstaste = await _tastesServices.GetSweetnessTastesAsync();

            var user = await _userManager.FindByEmailAsync(User.Identity.Name);

            TastesVM tvm = new TastesVM
            {
                ListColours   = await _filtersServices.GetColourAsync(),
                ListSources   = await _filtersServices.GetSourceAsync(),
                ListSweetness = await _filtersServices.GetSweetnesAsync(),

                SourceTastes   = sourcetaste.Where(x => x.AppUser.Id == user.Id).ToList(),
                ColourTastes   = colourtaste.Where(x => x.AppUser.Id == user.Id).ToList(),
                SweetnesTastes = sweetnesstaste.Where(x => x.AppUser.Id == user.Id).ToList(),
            };

            return(View(tvm));
        }