public ActionResult AddNewMeeting(AddMeetingViewModel newMeeting) { if (ModelState.IsValid) { Meeting meeting = new Meeting { MeetingIdentificator = ObjectId.GenerateNewId().ToString(), MeetingIndexer = newMeeting.MeetingIndexer, Description = newMeeting.Description, DateOfMeeting = newMeeting.DateOfMeeting, Country = newMeeting.Country, City = newMeeting.City, PostCode = newMeeting.PostCode, Address = newMeeting.Address, NumberOfApartment = newMeeting.NumberOfApartment, // instructors }; _context.AddMeeting(meeting); return(RedirectToAction("AddNewMeetingConfirmation", new { meetingIdentificator = meeting.MeetingIdentificator })); } newMeeting.AvailableCourses = _context.GetCoursesAsSelectList().ToList(); return(View(newMeeting)); }
public ActionResult AddNewCourseConfirmation(string courseIdentificator, ICollection <string> MeetingsIdentificators) { if (courseIdentificator != null) { var Course = _context.GetCourseById(courseIdentificator); AddCourseViewModel addedCourse = new AddCourseViewModel { CourseIndexer = Course.CourseIndexer, Name = Course.Name, Description = Course.Description, DateOfStart = Course.DateOfStart, DateOfEnd = Course.DateOfEnd, MeetingsViewModels = new List <AddMeetingViewModel>() }; if (Course.Meetings != null) { var MeetingsId = _context.GetMeetingsById(Course.Meetings); List <AddMeetingViewModel> Meetings = new List <AddMeetingViewModel>(); foreach (var meeting in MeetingsId) { var Instructors = _context.GetInstructorsById(meeting.Instructor); AddMeetingViewModel meetingsInCourse = new AddMeetingViewModel { MeetingIndexer = meeting.MeetingIndexer, Description = meeting.Description, DateOfMeeting = meeting.DateOfMeeting, Country = meeting.Country, City = meeting.City, PostCode = meeting.PostCode, Address = meeting.Address, NumberOfApartment = meeting.NumberOfApartment, Instructors = new List <string>() }; foreach (var instructor in Instructors) { string instructorIdentity = instructor.FirstName + instructor.LastName; meetingsInCourse.Instructors.Add(instructorIdentity); } Meetings.Add(meetingsInCourse); } addedCourse.MeetingsViewModels = Meetings; } var BranchNames = _context.GetBranchesById(Course.Branches); addedCourse.SelectedBranches = BranchNames; return(View(addedCourse)); } return(RedirectToAction(nameof(AddNewCourse))); }
public ActionResult AddNewMeeting() { AddMeetingViewModel newMeeting = new AddMeetingViewModel { AvailableCourses = _context.GetCoursesAsSelectList().ToList() }; return(View(newMeeting)); }
public ActionResult AddNewMeeting(string courseIdentificator) { AddMeetingViewModel newMeeting = new AddMeetingViewModel { AvailableCourses = _context.courseRepository.GetActiveCoursesAsSelectList().ToList(), AvailableInstructors = _context.userRepository.GetInstructorsAsSelectList().ToList() }; if (!string.IsNullOrWhiteSpace(courseIdentificator)) { newMeeting.SelectedCourse = courseIdentificator; } return(View(newMeeting)); }
public ActionResult AddNewMeeting(AddMeetingViewModel newMeeting) { if (ModelState.IsValid) { Meeting meeting = _mapper.Map <Meeting>(newMeeting); meeting.MeetingIdentificator = _keyGenerator.GenerateNewId(); var course = _context.courseRepository.GetCourseById(newMeeting.SelectedCourse); meeting.MeetingIndexer = _keyGenerator.GenerateMeetingEntityIndexer(course.CourseIndexer); _context.meetingRepository.AddMeeting(meeting); _context.courseRepository.AddMeetingToCourse(meeting.MeetingIdentificator, newMeeting.SelectedCourse); #region EntityLogs var logInfoAddMeeting = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[0], LogDescriptions.DescriptionOfActionOnEntity["addMeeting"]); _logger.AddMeetingLog(meeting, logInfoAddMeeting); var updatedCourse = _context.courseRepository.GetCourseById(newMeeting.SelectedCourse); var logInfoUpdateCourse = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["addMeeting"]); _logger.AddCourseLog(updatedCourse, logInfoUpdateCourse); #endregion #region PersonalUserLogs var logInfoPersonalAddMeeting = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addMeeting"], "Indekser: " + meeting.MeetingIndexer); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddMeeting); var logInfoPersonalAddMeetingToCourse = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addMeetingToCourse"], "Indekser: " + course.CourseIndexer); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddMeetingToCourse); var logInfoPersonalAddInstructorsToMeeting = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addInstructorToMeeting"], "Indekser: " + meeting.MeetingIndexer); _context.personalLogRepository.AddPersonalUsersLogs(meeting.Instructors, logInfoPersonalAddInstructorsToMeeting); #endregion return(RedirectToAction("ConfirmationOfActionOnMeeting", new { meetingIdentificator = meeting.MeetingIdentificator, TypeOfAction = "Add" })); } newMeeting.AvailableCourses = _context.courseRepository.GetActiveCoursesAsSelectList().ToList(); newMeeting.AvailableInstructors = _context.userRepository.GetInstructorsAsSelectList().ToList(); return(View(newMeeting)); }