예제 #1
0
        public async Task UpdateDiscountLevel(DiscountLevelViewModel viewModel)
        {
            viewModel.DiscountPercentage = viewModel.DiscountPercentage / 100;
            var discountLevel = _mapper.Map <DiscountLevel>(viewModel);

            _context.DiscountLevels.Update(discountLevel);
            await _context.SaveChangesAsync();
        }
예제 #2
0
        public async Task <DiscountLevelViewModel> GetDiscounts()
        {
            var viewModel = new DiscountLevelViewModel()
            {
                Discounts = await _context.Discounts.ToListAsync()
            };

            return(viewModel);
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, DiscountLevelViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                await _service.UpdateDiscountLevel(viewModel);

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