Inheritance: Decision.ViewModel.Common.BaseRowVersion
示例#1
0
 public async Task EditAsync(EditAddressViewModel viewModel)
 {
     var address = await _addresses.FirstAsync(a => a.Id == viewModel.Id);
     _mappingEngine.Map(viewModel, address);
 }
示例#2
0
 public void FillEditViewModel(EditAddressViewModel viewModel, string path)
 {
     viewModel.States = _stateService.GetAsSelectListItemAsync(viewModel.State, path);
     viewModel.Cities = _cityService.GetAsSelectListByStateNameAsync(viewModel.State, viewModel.City, path);
 }
示例#3
0
        public virtual async Task<ActionResult> Edit(EditAddressViewModel viewModel)
        {
            if (!_referentialTeacherService.CanManageTeacher(viewModel.TeacherId)) return HttpNotFound();

            if (!await _addressService.IsInDb(viewModel.Id))
                this.AddErrors("Location", "آدرس مورد نظر توسط یکی از کاربران در شبکه،حذف شده است");

            if (!ModelState.IsValid)
            {
                _addressService.FillEditViewModel(viewModel, IranCitiesPath);
                return new JsonNetResult
                {
                    Data = new
                    {
                        success = false,
                        View = this.RenderPartialViewToString(MVC.Address.Views._Edit, viewModel)
                    }
                };
            }

            
            await _addressService.EditAsync(viewModel);
            var message = await _unitOfWork.ConcurrencySaveChangesAsync();
            if (message.HasValue())
                this.AddErrors("Location", string.Format(message, "آدرس"));

            if (ModelState.IsValid)
            {
                var address = await _addressService.GetAddressViewModel(viewModel.Id);
                return new JsonNetResult
                {
                    Data = new
                    {
                        success = true,
                        View = this.RenderPartialViewToString(MVC.Address.Views._AddressItem, address)
                    }
                };
            }
            _addressService.FillEditViewModel(viewModel, IranCitiesPath);
            return new JsonNetResult
            {
                Data = new
                {
                    success = false,
                    View = this.RenderPartialViewToString(MVC.Address.Views._Edit, viewModel)
                }
            };
        }
示例#4
0
        public virtual async Task<ActionResult> Edit(EditAddressViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                _addressService.FillEditViewModel(viewModel, IranCitiesPath);
                return new JsonNetResult
                {
                    Data = new
                    {
                        success = false,
                        View = this.RenderPartialViewToString(MVC.Address.Views._Edit, viewModel)
                    }
                };
            }
            await _addressService.EditAsync(viewModel);
            await _unitOfWork.SaveAllChangesAsync(auditUserId: _userManager.GetCurrentUserId());

            if (ModelState.IsValid)
            {
                var address = await _addressService.GetAddressViewModel(viewModel.Id);
                return new JsonNetResult
                {
                    Data = new
                    {
                        success = true,
                        View = this.RenderPartialViewToString(MVC.Address.Views._AddressItem, address)
                    }
                };
            }
            _addressService.FillEditViewModel(viewModel, IranCitiesPath);
            return new JsonNetResult
            {
                Data = new
                {
                    success = false,
                    View = this.RenderPartialViewToString(MVC.Address.Views._Edit, viewModel)
                }
            };
        }
示例#5
0
 public async Task EditAsync(EditAddressViewModel viewModel)
 {
     var address = await _addresses.FirstAsync(a => a.Id == viewModel.Id);
     _mappingEngine.Map(viewModel, address);
     address.LasModifierId = _userManager.GetCurrentUserId();
 }