Exemplo n.º 1
0
        public async Task <IActionResult> DeleteWineList(int winwListId)
        {
            WineList wineList = await _wineListsServices.GetWineListByIdAsync(winwListId);

            await _wineListsServices.DeleteWineListAsync(wineList);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public async Task DeleteWineListAsync(WineList wineList)
        {
            foreach (WineListWine wineListWine in await _context.WineListWines.Where(x => x.WineListId == wineList.Id).ToListAsync())
            {
                _context.WineListWines.Remove(wineListWine);
            }

            _context.WineLists.Remove(wineList);
            await _context.SaveChangesAsync();
        }
Exemplo n.º 3
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());
        }
Exemplo n.º 4
0
 private void DeleteWineButton_Click(object sender, System.EventArgs e)
 {
     var selectedRows = WineTable.SelectedRows;
     foreach(DataGridViewRow row in selectedRows)
     {
         int id = Convert.ToInt32(row.Cells[0].Value);
         WineManager.DeleteData(id);
         Wine local = WineList.Find(x => x.Id == id);
         WineList.Remove(local);
     }
     UpdateWineTable();
 }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,ListName,Description")] WineList wineList)
        {
            var user = await _userManager.FindByEmailAsync(User.Identity.Name);

            wineList.AppUserId = user.Id;
            wineList.ListDate  = DateTime.Now;
            if (ModelState.IsValid)
            {
                await _wineListsServices.CreateWineListAsync(wineList);

                return(RedirectToAction(nameof(Index)));
            }

            return(View(wineList));
        }
Exemplo n.º 6
0
        private WineList SaveWineItem(UpcDbModel wineInfo, WineVarieties wineVariety)
        {
            var wineData = new WineList()
            {
                Upc                    = wineInfo.UpcCode,
                AlchoholLevel          = (int?)wineInfo.AlchoholLevel,
                WineVarietiesVarietyId = wineVariety.VarietyId,
                Region                 = wineInfo.Region,
                Producer               = wineInfo.Winery ?? "N/A",
                Vintage                = wineInfo.Year,
                Size                   = wineInfo.Size,
            };

            if (wineData.Upc.IsNullOrEmpty())
            {
                wineData.Upc = GetInternalBarCode();
            }

            if (wineData.Region.IsNullOrEmpty())
            {
                wineData.Region = string.Empty;
            }

            if (wineData.Size == 0)
            {
                wineData.Size = 750;
            }

            wineData.CreatedDate = DateTime.UtcNow;
            _context.WineList.Add(wineData);
            _context.SaveChanges();

            _processLog.WriteLine("UPC: " + wineData.Upc + " Saving item: " + wineInfo.WineName + " -  " + wineInfo.Varietal + ", " + wineInfo.Winery);
            Console.Write(".");
            return(wineData);
        }
Exemplo n.º 7
0
        //
        public async Task CreateWineListAsync(WineList wineList)
        {
            await _context.AddAsync(wineList);

            await _context.SaveChangesAsync();
        }