public virtual ActionResult Create(Guid centerId) { var viewModel = new AddTrainingCourseViewModel { TrainingCenterId = centerId }; return PartialView(MVC.TrainingCourse.Views._Create, viewModel); }
public async Task<TrainingCourseViewModel> Create(AddTrainingCourseViewModel viewModel) { var course = _mappingEngine.Map<TrainingCourse>(viewModel); course.CreatorId = _userManager.GetCurrentUserId(); _courses.Add(course); await _unitOfWork.SaveChangesAsync(); return await GetTrainingCourseViewModel(course.Id); }
//[CheckReferrer] public virtual async Task<ActionResult> Create(AddTrainingCourseViewModel viewModel) { if (await _trainingCourseService.IsExistCourseCode(viewModel.CourseCode, null, viewModel.TrainingCenterId)) this.AddErrors("CourseCode", "یک دوره با این کد برای مرکز قبلا در سیستم ثبت شده است"); if (!ModelState.IsValid) { return new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.TrainingCourse.Views._Create, viewModel) } }; } var newCourse =await _trainingCourseService.Create(viewModel); return new JsonNetResult { Data = new { success = true, View = this.RenderPartialViewToString(MVC.TrainingCourse.Views._TrainingCourseItem, newCourse) } }; }