public virtual async Task<ActionResult> Edit(EditEducationalExperienceViewModel viewModel) { if (!await _educationalExperienceService.IsInDb(viewModel.Id)) if (!ModelState.IsValid) { await _educationalExperienceService.FillEditViewModel(viewModel); return new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.ScientificTeaching.Views._Edit, viewModel) } }; } await _educationalExperienceService.EditAsync(viewModel); var message = await _unitOfWork.ConcurrencySaveChangesAsync(); if (message.HasValue()) this.AddErrors("TitleId", string.Format(message, "سابقه تدریس علمی استاد")); if (ModelState.IsValid) { var ScientificTeaching = await _educationalExperienceService.GetEducationalExperienceViewModel(viewModel.Id); return new JsonNetResult { Data = new { success = true, View = this.RenderPartialViewToString(MVC.ScientificTeaching.Views._ScientificTeachingItem, ScientificTeaching) } }; } await _educationalExperienceService.FillEditViewModel(viewModel); return new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.ScientificTeaching.Views._Edit, viewModel) } }; }
public async Task EditAsync(EditEducationalExperienceViewModel viewModel) { var educationalExperience = await _educationalExperiences.FirstAsync(a => a.Id == viewModel.Id); _mappingEngine.Map(viewModel, educationalExperience); educationalExperience.LasModifierId = _userManager.GetCurrentUserId(); }
public virtual async Task<ActionResult> Edit(EditEducationalExperienceViewModel viewModel) { if (!_referentialTeacherService.CanManageTeacher(viewModel.TeacherId)) return HttpNotFound(); if (!await _educationalExperienceService.IsInDb(viewModel.Id)) this.AddErrors("TitleId", "موضوع مورد علاقه مورد نظر توسط یکی از کاربران در شبکه،حذف شده است"); if (!ModelState.IsValid) { await _educationalExperienceService.FillEditViewModel(viewModel); return new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.FavoriteIssue.Views._Edit, viewModel) } }; } await _educationalExperienceService.EditAsync(viewModel); var message = await _unitOfWork.ConcurrencySaveChangesAsync(); if (message.HasValue()) this.AddErrors("TitleId", string.Format(message, "اولویت تصویب شده برای استاد")); if (ModelState.IsValid) { var FavoriteIssue = await _educationalExperienceService.GetEducationalExperienceViewModel(viewModel.Id); return new JsonNetResult { Data = new { success = true, View = this.RenderPartialViewToString(MVC.FavoriteIssue.Views._FavoriteIssueItem, FavoriteIssue) } }; } await _educationalExperienceService.FillEditViewModel(viewModel); return new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.FavoriteIssue.Views._Edit, viewModel) } }; }
public async Task FillEditViewModel(EditEducationalExperienceViewModel viewModel) { viewModel.Titles = await _titleService.GetAsSelectListItemAsync(TitleType.CourseContent, viewModel.TitleId); }
public virtual async Task<ActionResult> Edit(EditEducationalExperienceViewModel viewModel) { if (!await _educationalExperienceService.IsInDb(viewModel.Id)) if (!ModelState.IsValid) { return new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.EducationalExperience.Views._Edit, viewModel) } }; } await _educationalExperienceService.EditAsync(viewModel); await _unitOfWork.SaveAllChangesAsync(auditUserId: _userManager.GetCurrentUserId()); var educationalExperience = await _educationalExperienceService.GetEducationalExperienceViewModel(viewModel.Id); return new JsonNetResult { Data = new { success = true, View = this.RenderPartialViewToString(MVC.EducationalExperience.Views._EducationalExperienceItem, educationalExperience) } }; }