public async Task <IActionResult> Edit(int id, [Bind("ID,Kategoria,Nev,Ar,Allergen,Leiras,Kedvezmeny")] Etlap etlap) { var user = await _userManager.GetUserAsync(HttpContext.User); if (id != etlap.ID) { return(NotFound()); } if (ModelState.IsValid) { try { etlap.IdentityUser = user; int ujar = etlap.Ar; double merteke = 0; if (etlap.Kedvezmeny != null) { var valami = Convert.ToDouble(etlap.Kedvezmeny); merteke = etlap.Ar * (valami / 100); } etlap.Ar = ujar - Convert.ToInt32(merteke); _context.Add(etlap); _context.Update(etlap); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EtlapExists(etlap.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(etlap)); }
public async Task <IActionResult> Create([Bind("ID,Kategoria,Nev,Ar,Allergen,Leiras,Kedvezmeny")] Etlap etlap) { var user = await _userManager.GetUserAsync(HttpContext.User); if (ModelState.IsValid) { etlap.IdentityUser = user; int ujar = etlap.Ar; double merteke = 0; if (etlap.Kedvezmeny != null) { var valami = Convert.ToDouble(etlap.Kedvezmeny); merteke = etlap.Ar * (valami / 100); } etlap.Ar = ujar - Convert.ToInt32(merteke); _context.Add(etlap); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(etlap)); }