Пример #1
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)
                }
            });
        }