Пример #1
0
 public virtual ActionResult Create(Guid centerId)
 {
     var viewModel = new AddTrainingCourseViewModel
     {
         TrainingCenterId = centerId
     };
     return PartialView(MVC.TrainingCourse.Views._Create, viewModel);
 }
Пример #2
0
 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);
 }
Пример #3
0
 //[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)
             }
     };
 }