public async Task EditAsync(EditTeacherInServiceCourseTypeViewModel viewModel) { var TeacherInServiceCourseType = await _TeacherInServiceCourseTypes.FirstAsync(a => a.Id == viewModel.Id); _mappingEngine.Map(viewModel, TeacherInServiceCourseType); TeacherInServiceCourseType.LasModifierId = _userManager.GetCurrentUserId(); }
public virtual async Task<ActionResult> Edit(EditTeacherInServiceCourseTypeViewModel viewModel) { if (!await _TeacherInServiceCourseType.IsInDb(viewModel.Id)) this.AddErrors("TitleId", "دوزه ضمن خدمت مورد نظر توسط یکی از کاربران در شبکه ، حذف است"); if (!ModelState.IsValid) { await _TeacherInServiceCourseType.FillEditViewModel(viewModel); return new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.TeacherInServiceCourseType.Views._Edit, viewModel) } }; } await _TeacherInServiceCourseType.EditAsync(viewModel); var message = await _unitOfWork.ConcurrencySaveChangesAsync(); if (message.HasValue()) this.AddErrors("TitleId", string.Format(message, "دوره ضمن خدمت")); if (ModelState.IsValid) { var TeacherInServiceCourseType = await _TeacherInServiceCourseType.GetTeacherInServiceCourseTypeViewModel(viewModel.Id); return new JsonNetResult { Data = new { success = true, View = this.RenderPartialViewToString(MVC.TeacherInServiceCourseType.Views._TeacherInServiceCourseTypeItem, TeacherInServiceCourseType) } }; } await _TeacherInServiceCourseType.FillEditViewModel(viewModel); return new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.TeacherInServiceCourseType.Views._Edit, viewModel) } }; }
public async Task FillEditViewModel(EditTeacherInServiceCourseTypeViewModel viewModel) { viewModel.InServiceCourseTypeTitles = await _titleService.GetAsSelectListItemAsync(TitleType.InServiceCourseType, viewModel.InServiceCourseTypeTitleId); }