public PartialViewResult _MakeApplicationToLessonPartial( MakeApplicationToLessonViewModel applicationToLessonViewModel) { applicationToLessonViewModel.Lessons = GetLessonSelectList(); try { if (ModelState.IsValid) { if (this.VerifyRecaptchaResponse()) { var lessonApplicationDto = Mapper.Map<LessonApplicationCreatingDto>( applicationToLessonViewModel); string lessonName = applicationToLessonViewModel.Lessons .FirstOrDefault(l => l.Value == applicationToLessonViewModel.LessonId.ToString()) .Text; var notification = new Notification( ConfigurationManager.AppSettings["EmailForNotifications"], Resources.Resource.MakeApplicationToLessonNotificationSubject, String.Format( Resources.Resource.MakeApplicationToLessonNotificationBody, applicationToLessonViewModel.LearnerName, applicationToLessonViewModel.LearnerPhone, applicationToLessonViewModel.LearnerEmail, applicationToLessonViewModel.LearnerCount, lessonName, applicationToLessonViewModel.LessonCount, applicationToLessonViewModel.Comment)); lock (_updateLocker) { _managementService.CreateLessonApplication( lessonApplicationDto, notification); } ModelState.Clear(); return _MakeApplicationToLessonPartial( applicationToLessonViewModel.LessonId, true); } else { ModelState.AddModelError(string.Empty, _invalidCaptchaError); } } } catch (Exception ex) { ModelState.AddModelError(String.Empty, _generalError); _logger.Error( ex, "Не удалось оформить заявку на занятие viewModel='{0}'", applicationToLessonViewModel); } return PartialView(applicationToLessonViewModel); }
public PartialViewResult _MakeApplicationToLessonPartial( int? lessonId = null, bool successfullyMade = false) { var applicationToLessonViewModel = new MakeApplicationToLessonViewModel() { LearnerCount = 1, LessonCount = 1, LessonId = lessonId ?? 0, SuccessfullyMade = successfullyMade }; applicationToLessonViewModel.Lessons = GetLessonSelectList(); return PartialView(applicationToLessonViewModel); }