public async Task UpdateDiscountLevel(DiscountLevelViewModel viewModel) { viewModel.DiscountPercentage = viewModel.DiscountPercentage / 100; var discountLevel = _mapper.Map <DiscountLevel>(viewModel); _context.DiscountLevels.Update(discountLevel); await _context.SaveChangesAsync(); }
public async Task <DiscountLevelViewModel> GetDiscounts() { var viewModel = new DiscountLevelViewModel() { Discounts = await _context.Discounts.ToListAsync() }; return(viewModel); }
public async Task <IActionResult> Edit(int id, DiscountLevelViewModel viewModel) { if (ModelState.IsValid) { await _service.UpdateDiscountLevel(viewModel); return(RedirectToAction(nameof(Index))); } return(View(viewModel)); }