public async Task UpdateDiscount(ProductDiscountUpdateViewModel vm) { var model = await GetByIdAsync(vm.Id); Mapper.Map(vm, model); await DbContext.SaveChangesAsync(); }
public async Task <IActionResult> ProductDiscountUpdate(ProductDiscountUpdateViewModel vm, decimal PriceDiscount, decimal PercentDicount) { if (vm.StartDate >= vm.EndDate) { TempData.AddResult(SweetAlertExtenstion.Error("تاریخ شروع تخفیف نمی تواند از تاریخ پایان آن کوچکتر باشد")); return(RedirectToAction("Index", "ManageProduct", new { area = "Product" })); } vm.Discount = vm.DiscountType == DataLayer.SSOT.ProductDiscountSSOT.Percent ? PercentDicount : PriceDiscount; await _productDiscountRepository.UpdateDiscount(vm); TempData.AddResult(SweetAlertExtenstion.Ok()); return(Redirect("/Product/ManageProduct/Index")); }