public ActionResult DeleteBranch(DeleteEntityViewModel branchToDelete) { var user = _context.userRepository.GetUserByEmail(this.User.Identity.Name); var branch = _context.branchRepository.GetBranchById(branchToDelete.EntityIdentificator); if (branch == null) { return(RedirectToAction("UniversalConfirmationPanel", "Account", new { messageNumber = 6, returnUrl = Url.BlankMenuLink(Request.Scheme) })); } if (ModelState.IsValid && _keyGenerator.ValidateUserTokenForEntityDeletion(user, branchToDelete.Code)) { _context.branchRepository.DeleteBranch(branchToDelete.EntityIdentificator); #region EntityLogs var logInfoDeleteBranch = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[2], LogDescriptions.DescriptionOfActionOnEntity["deleteBranch"]); var logInfoUpdateCertificate = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["updateCertificate"]); var logInfoUpdateDegree = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["updateDegree"]); var logInfoUpdateCourse = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["updateCourse"]); _logger.AddBranchLog(branch, logInfoDeleteBranch); var updatedCourses = _context.courseRepository.DeleteBranchFromCourses(branch.BranchIdentificator); _logger.AddCoursesLogs(updatedCourses, logInfoUpdateCourse); var updatedCertificates = _context.certificateRepository.DeleteBranchFromCertificates(branch.BranchIdentificator); _logger.AddCertificatesLogs(updatedCertificates, logInfoUpdateCertificate); var updatedDegrees = _context.degreeRepository.DeleteBranchFromDegrees(branch.BranchIdentificator); _logger.AddDegreesLogs(updatedDegrees, logInfoUpdateDegree); #endregion #region PersonalUserLogs var logInfoPersonal = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteBranch"], "Nazwa: " + branch.Name); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonal); #endregion return(RedirectToAction("DisplayAllBranches", "Branches", new { message = "Usunięto wskazany obszar certyfikacji" })); } return(View("DeleteEntity", branchToDelete)); }
public ActionResult DeleteCertificate(string certificateIdentificator, string code) { if (!string.IsNullOrWhiteSpace(certificateIdentificator) && !string.IsNullOrWhiteSpace(code)) { DeleteEntityViewModel certificateToDelete = new DeleteEntityViewModel { EntityIdentificator = certificateIdentificator, Code = code, ActionName = this.ControllerContext.RouteData.Values["action"].ToString(), FormHeader = "Usuwanie certyfikatu" }; return(View("DeleteEntity", certificateToDelete)); } return(RedirectToAction("BlankMenu", "Certificates")); }
public ActionResult DeleteMeeting(string meetingIdentificator, string code) { if (!string.IsNullOrWhiteSpace(meetingIdentificator) && !string.IsNullOrWhiteSpace(code)) { DeleteEntityViewModel meetingToDelete = new DeleteEntityViewModel { EntityIdentificator = meetingIdentificator, Code = code, ActionName = this.ControllerContext.RouteData.Values["action"].ToString(), FormHeader = "Usuwanie spotkania w ramach kursu" }; return(View("DeleteEntity", meetingToDelete)); } return(RedirectToAction("BlankMenu", "Certificates")); }
public ActionResult DeleteGivenDegree(string givenDegreeIdentificator, string code) { if (!string.IsNullOrWhiteSpace(givenDegreeIdentificator) && !string.IsNullOrWhiteSpace(code)) { DeleteEntityViewModel givenDegreeToDelete = new DeleteEntityViewModel { EntityIdentificator = givenDegreeIdentificator, Code = code, ActionName = this.ControllerContext.RouteData.Values["action"].ToString(), FormHeader = "Usuwanie nadanego stopnia zawodowego" }; return(View("DeleteEntity", givenDegreeToDelete)); } return(RedirectToAction("BlankMenu", "Certificates")); }
public ActionResult DeleteMeeting(DeleteEntityViewModel meetingToDelete) { var user = _context.userRepository.GetUserByEmail(this.User.Identity.Name); var meeting = _context.meetingRepository.GetMeetingById(meetingToDelete.EntityIdentificator); if (meeting == null) { return(RedirectToAction("UniversalConfirmationPanel", "Account", new { messageNumber = 6, returnUrl = Url.BlankMenuLink(Request.Scheme) })); } if (ModelState.IsValid && _keyGenerator.ValidateUserTokenForEntityDeletion(user, meetingToDelete.Code)) { _context.meetingRepository.DeleteMeeting(meetingToDelete.EntityIdentificator); var course = _context.courseRepository.GetCourseByMeetingId(meeting.MeetingIdentificator); #region EntityLogs var logInfoDeleteMeeting = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[2], LogDescriptions.DescriptionOfActionOnEntity["deleteMeeting"]); var logInfoUpdateCourse = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["removeMeetingFromCourse"]); _logger.AddMeetingLog(meeting, logInfoDeleteMeeting); var updatedCourse = _context.courseRepository.DeleteMeetingFromCourse(meetingToDelete.EntityIdentificator); _logger.AddCourseLog(updatedCourse, logInfoUpdateCourse); #endregion #region PersonalUserLogs var logInfoPersonalDeleteMeeting = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteMeeting"], "Indekser: " + meeting.MeetingIndexer); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalDeleteMeeting); var logInfoPersonalDeleteUserMeeting = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteUserMeeting"], "Indekser: " + meeting.MeetingIndexer); _context.personalLogRepository.AddPersonalUsersLogs(course.EnrolledUsers, logInfoPersonalDeleteUserMeeting); _context.personalLogRepository.AddPersonalUsersLogs(meeting.Instructors, logInfoPersonalDeleteUserMeeting); #endregion return(RedirectToAction("DisplayAllMeetings", "Meetings", new { message = "Usunięto wskazane spotkanie" })); } return(View("DeleteEntity", meetingToDelete)); }
public ActionResult DeleteGivenCertificate(DeleteEntityViewModel givenCertificateToDelete) { var user = _context.userRepository.GetUserByEmail(this.User.Identity.Name); var givenCertificate = _context.givenCertificateRepository.GetGivenCertificateById(givenCertificateToDelete.EntityIdentificator); if (givenCertificate == null) { return(RedirectToAction("UniversalConfirmationPanel", "Account", new { messageNumber = 6, returnUrl = Url.BlankMenuLink(Request.Scheme) })); } if (ModelState.IsValid && _keyGenerator.ValidateUserTokenForEntityDeletion(user, givenCertificateToDelete.Code)) { _context.givenCertificateRepository.DeleteGivenCertificate(givenCertificateToDelete.EntityIdentificator); #region EntityLogs var logInfoDeleteGivenCertificate = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[2], LogDescriptions.DescriptionOfActionOnEntity["deleteGivenCertificate"]); _logger.AddGivenCertificateLog(givenCertificate, logInfoDeleteGivenCertificate); var logInfoUpdateUser = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["deleteUserGivenCertificate"]); var updatedUser = _context.userRepository.DeleteUserGivenCertificate(givenCertificateToDelete.EntityIdentificator); _logger.AddUserLog(updatedUser, logInfoUpdateUser); #endregion #region PersonalUserLogs var logInfoPersonalDeleteGivenCertificate = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteGivenCertificate"], "Indekser: " + givenCertificate.GivenCertificateIndexer); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalDeleteGivenCertificate); var logInfoPersonalDeleteUserGivenCertificate = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteUserGivenCertificate"], "Indekser: " + givenCertificate.GivenCertificateIndexer); _context.personalLogRepository.AddPersonalUserLog(user.Id, logInfoPersonalDeleteUserGivenCertificate); #endregion return(RedirectToAction("DisplayAllGivenCertificates", "GivenCertificates", new { message = "Usunięto wskazany nadany certyfikat" })); } return(View("DeleteEntity", givenCertificateToDelete)); }
public ActionResult DeleteCompany(DeleteEntityViewModel companyToDelete) { var user = _context.userRepository.GetUserByEmail(this.User.Identity.Name); var company = _context.companyRepository.GetCompanyById(companyToDelete.EntityIdentificator); if (company == null) { return(RedirectToAction("UniversalConfirmationPanel", "Account", new { messageNumber = 6, returnUrl = Url.BlankMenuLink(Request.Scheme) })); } if (ModelState.IsValid && _keyGenerator.ValidateUserTokenForEntityDeletion(user, companyToDelete.Code)) { _context.companyRepository.DeleteCompany(companyToDelete.EntityIdentificator); #region EntityLogs var logInfoDeleteCompany = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[2], LogDescriptions.DescriptionOfActionOnEntity["deleteCompany"]); var logInfoUpdateUsers = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["updateUsers"]); _logger.AddCompanyLog(company, logInfoDeleteCompany); var updatedUsers = _context.userRepository.DeleteCompanyFromUsers(companyToDelete.EntityIdentificator); _logger.AddUsersLogs(updatedUsers, logInfoUpdateUsers); #endregion #region PersonalUserLogs var logInfoPersonalDeleteCompany = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteCompany"], "Nazwa przedsiębiorstwa: " + company.CompanyName); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalDeleteCompany); var logInfoPersonalDeleteUserCompany = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteUserCompany"], "Nazwa przedsiębiorstwa: " + company.CompanyName); _context.personalLogRepository.AddPersonalUsersLogs(updatedUsers.Select(z => z.Id).ToList(), logInfoPersonalDeleteUserCompany); #endregion return(RedirectToAction("DisplayAllCertificates", "Certificates", new { message = "Usunięto wskazane przedsiębiorstwo" })); } return(View("DeleteEntity", companyToDelete)); }
public ActionResult DeleteCertificate(DeleteEntityViewModel certificateToDelete) { var user = _context.userRepository.GetUserByEmail(this.User.Identity.Name); var certificate = _context.certificateRepository.GetCertificateById(certificateToDelete.EntityIdentificator); if (certificate == null) { return(RedirectToAction("UniversalConfirmationPanel", "Account", new { messageNumber = 6, returnUrl = Url.BlankMenuLink(Request.Scheme) })); } if (ModelState.IsValid && _keyGenerator.ValidateUserTokenForEntityDeletion(user, certificateToDelete.Code)) { _context.certificateRepository.DeleteCertificate(certificateToDelete.EntityIdentificator); #region EntityLogs var logInfoDeleteCertificate = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[2], LogDescriptions.DescriptionOfActionOnEntity["deleteCertificate"]); var logInfoDeleteGivenCertificate = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[2], LogDescriptions.DescriptionOfActionOnEntity["deleteGivenCertificate"]); var logInfoDeleteRequiredCertificateFromGivenDegrees = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[2], LogDescriptions.DescriptionOfActionOnEntity["deleteRequiredGivenCertificateFromDegree"]); var logInfoUpdateUsers = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["deleteUserGivenCertificate"]); _logger.AddCertificateLog(certificate, logInfoDeleteCertificate); var deletedGivenCertificates = _context.givenCertificateRepository.DeleteGivenCertificatesByCertificateId(certificateToDelete.EntityIdentificator); _logger.AddGivenCertificatesLogs(deletedGivenCertificates, logInfoDeleteGivenCertificate); var degreesWhichHasDeletedRequiredCertificate = _context.degreeRepository.DeleteRequiredCertificateFromDegrees(certificateToDelete.EntityIdentificator); _logger.AddDegreesLogs(degreesWhichHasDeletedRequiredCertificate, logInfoDeleteRequiredCertificateFromGivenDegrees); var updatedUsers = _context.userRepository.GetUsersByGivenCertificatesId(deletedGivenCertificates.Select(z => z.GivenCertificateIdentificator).ToList()); _logger.AddUsersLogs(updatedUsers, logInfoUpdateUsers); #endregion #region PersonalUserLogs var logInfoPersonalDeleteCertificate = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteCertificate"], "Indekser: " + certificate.CertificateIndexer); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalDeleteCertificate); foreach (var deletedGivenCertificate in deletedGivenCertificates) { var logInfoPersonalDeleteGivenCertificate = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteGivenCertificate"], "Indekser: " + deletedGivenCertificate.GivenCertificateIndexer); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalDeleteGivenCertificate); var deletedGivenCertificateOwner = _context.userRepository.GetUserByGivenCertificateId(deletedGivenCertificate.GivenCertificateIdentificator); var logInfoPersonalDeleteUserGivenCertificate = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteUserGivenCertificate"], "Indekser: " + deletedGivenCertificate.GivenCertificateIndexer); _context.personalLogRepository.AddPersonalUserLog(deletedGivenCertificateOwner.Id, logInfoPersonalDeleteUserGivenCertificate); } foreach (var deletedGivenCertificate in deletedGivenCertificates) { var logInfoPersonalDeleteGivenCertificate = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteGivenCertificate"], "Indekser: " + deletedGivenCertificate.GivenCertificateIndexer); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalDeleteGivenCertificate); var deletedGivenCertificateOwner = _context.userRepository.GetUserByGivenCertificateId(deletedGivenCertificate.GivenCertificateIdentificator); var logInfoPersonalDeleteUserGivenCertificate = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteUserGivenCertificate"], "Indekser: " + deletedGivenCertificate.GivenCertificateIndexer); _context.personalLogRepository.AddPersonalUserLog(deletedGivenCertificateOwner.Id, logInfoPersonalDeleteUserGivenCertificate); } foreach (var degreeWhichHasDeletedRequiredCertificate in degreesWhichHasDeletedRequiredCertificate) { var logInfoPersonalUpdateDegree = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["deleteRequiredCertificate"], "Indekser: " + degreeWhichHasDeletedRequiredCertificate.DegreeIndexer); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalUpdateDegree); var givenDegrees = _context.givenDegreeRepository.GetGivenDegreesByIdOfDegree(degreeWhichHasDeletedRequiredCertificate.DegreeIdentificator); foreach (var givenDegree in givenDegrees) { var ownerOfGivenDegree = _context.userRepository.GetUserByGivenDegreeId(givenDegree.GivenDegreeIdentificator); var logInfoPersonalUpdateUserGivenDegree = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["updateUserGivenDegree"], "Indekser " + givenDegree.GivenDegreeIndexer); _context.personalLogRepository.AddPersonalUserLog(ownerOfGivenDegree.Id, logInfoPersonalUpdateUserGivenDegree); } } #endregion return(RedirectToAction("DisplayAllCertificates", "Certificates", new { message = "Usunięto wskazany certyfikat" })); } return(View("DeleteEntity", certificateToDelete)); }