/// <summary>
        ///
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public async Task EditByViewModelAsync(ProductSellerEditViewModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            var productSeller = await _productSellers.FirstOrDefaultAsync(model => model.Id == viewModel.Id);

            _mapper.Map(productSeller, viewModel);
            await _unitOfWork.SaveAllChangesAsync(auditUserId : _httpContextManager.CurrentUserId());
        }
Esempio n. 2
0
        public virtual async Task <ActionResult> Edit(ProductSellerEditViewModel viewModel)
        {
            // Check
            if (viewModel == null)
            {
                return(View(MVC.Error.Views.BadRequest));
            }

            // Validation
            if (ModelState.IsValid == false)
            {
                return(View(MVC.ProductSeller.Views.Create));
            }

            // Result
            await _productSellerService.EditByViewModelAsync(viewModel);

            this.AddToastMessage("ویرایش فروشنده با موفقیت انجام شد", "", ToastType.Success);
            return(RedirectToAction(MVC.ProductSeller.List()));
        }