ویومدل مربوط به ویرایش سابقه کاری
Inheritance: Decision.ViewModel.Common.BaseRowVersion
Ejemplo n.º 1
0
        public virtual async Task<ActionResult> Edit(EditWorkExperienceViewModel viewModel)
        {
            if (!_referentialTeacherService.CanManageTeacher(viewModel.TeacherId)) return HttpNotFound();
            if (!await _workExperienceService.IsInDb(viewModel.Id))
                this.AddErrors("TitleId", "سابقه کاری مورد نظر توسط یکی از کاربران در شبکه،حذف شده است");

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

            await _workExperienceService.EditAsync(viewModel);
            var message = await _unitOfWork.ConcurrencySaveChangesAsync();
            if (message.HasValue()) this.AddErrors("TitleId", string.Format(message, "سابقه کاری "));

            if (ModelState.IsValid)
            {
                var work = await _workExperienceService.GetWorkExperienceViewModel(viewModel.Id);
                return new JsonNetResult
                {
                    Data = new
                    {
                        success = true,
                        View = this.RenderPartialViewToString(MVC.WorkExperience.Views._WorkExperienceItem, work)
                    }
                };
            }

            await _workExperienceService.FillEditViewModel(viewModel, IranCitiesPath);
            return new JsonNetResult
            {
                Data = new
                {
                    success = false,
                    View = this.RenderPartialViewToString(MVC.WorkExperience.Views._Edit, viewModel)
                }
            };
        }
Ejemplo n.º 2
0
 public async Task EditAsync(EditWorkExperienceViewModel viewModel)
 {
     var workExperience = await _workExperiences.FirstAsync(a => a.Id == viewModel.Id);
     _mappingEngine.Map(viewModel, workExperience);
     workExperience.LasModifierId = _userManager.GetCurrentUserId();
 }
Ejemplo n.º 3
0
 public async Task FillEditViewModel(EditWorkExperienceViewModel viewModel, string path)
 {
     viewModel.States = _stateService.GetAsSelectListItemAsync(viewModel.State, path);
     viewModel.Cities = _cityService.GetAsSelectListByStateNameAsync(viewModel.State, viewModel.City, path);
     viewModel.Titles = await _titleService.GetAsSelectListItemAsync(TitleType.OrganizationPostTitle, viewModel.TitleId);
 }
Ejemplo n.º 4
0
 public async Task EditAsync(EditWorkExperienceViewModel viewModel)
 {
     var workExperience = await _workExperiences.FirstAsync(a => a.Id == viewModel.Id);
     _mappingEngine.Map(viewModel, workExperience);
 }
Ejemplo n.º 5
0
 public async Task FillEditViewModel(EditWorkExperienceViewModel viewModel, string path)
 {
     viewModel.States = _stateService.GetAsSelectListItemAsync(viewModel.State, path);
     viewModel.Cities = _cityService.GetAsSelectListByStateNameAsync(viewModel.State, viewModel.City, path);
 }
Ejemplo n.º 6
0
        public virtual async Task<ActionResult> Edit(EditWorkExperienceViewModel viewModel)
        {

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

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

            await _workExperienceService.EditAsync(viewModel);
            await _unitOfWork.SaveAllChangesAsync();
            
            var work = await _workExperienceService.GetWorkExperienceViewModel(viewModel.Id);
            return new JsonNetResult
            {
                Data = new
                {
                    success = true,
                    View = this.RenderPartialViewToString(MVC.WorkExperience.Views._WorkExperienceItem, work)
                }
            };
        }