diff --git a/CandidateReviewBusiness/CandidateReviewBusiness.csproj b/CandidateReviewBusiness/CandidateReviewBusiness.csproj deleted file mode 100644 index fa71b7a..0000000 --- a/CandidateReviewBusiness/CandidateReviewBusiness.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net8.0 - enable - enable - - - diff --git a/CandidateReviewBusiness/Class1.cs b/CandidateReviewBusiness/Class1.cs deleted file mode 100644 index f6f3b1d..0000000 --- a/CandidateReviewBusiness/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CandidateReviewBusiness -{ - public class Class1 - { - - } -} diff --git a/CandidateReviewClientApp/Controllers/ResumeController.cs b/CandidateReviewClientApp/Controllers/ResumeController.cs index 0cef98d..55ca2d0 100644 --- a/CandidateReviewClientApp/Controllers/ResumeController.cs +++ b/CandidateReviewClientApp/Controllers/ResumeController.cs @@ -207,7 +207,7 @@ namespace CandidateReviewClientApp.Controllers try { APIClient.PostRequest($"api/resume/delete", new ResumeBindingModel { Id = id }); - return Redirect("~/User/UserProfile"); + return Redirect($"~/User/UserProfile/{APIClient.User?.Id}"); } catch (Exception ex) { diff --git a/CandidateReviewClientApp/Controllers/UserController.cs b/CandidateReviewClientApp/Controllers/UserController.cs index ef5004e..f8c0896 100644 --- a/CandidateReviewClientApp/Controllers/UserController.cs +++ b/CandidateReviewClientApp/Controllers/UserController.cs @@ -70,9 +70,18 @@ namespace CandidateReviewClientApp.Controllers if (model.Id != 0) { APIClient.PostRequest("api/user/update", model); + if (model.Role == CandidateReviewDataModels.Enums.RoleEnum.Сотрудник) + { + return Redirect($"~/Company/CompanyProfile/{model.CompanyId}"); + } } else - { + { + var existingUser = APIClient.GetRequest($"api/user/login?login={model.Email}&password={model.Password}"); + if (existingUser != null) + { + throw new Exception("Такой пользователь уже существует"); + } APIClient.PostRequest("api/user/register", model); if (APIClient.Company != null) { diff --git a/CandidateReviewClientApp/Controllers/VacancyController.cs b/CandidateReviewClientApp/Controllers/VacancyController.cs index 5cf0788..66c5342 100644 --- a/CandidateReviewClientApp/Controllers/VacancyController.cs +++ b/CandidateReviewClientApp/Controllers/VacancyController.cs @@ -169,32 +169,48 @@ namespace CandidateReviewClientApp.Controllers public IActionResult Delete(int id) { - if (APIClient.Company == null) - { - throw new Exception("Компания не определена"); + string returnUrl = HttpContext.Request.Headers["Referer"].ToString(); + try + { + if (APIClient.Company == null) + { + throw new Exception("Компания не определена"); + } + + APIClient.PostRequest($"api/vacancy/delete", new VacancyBindingModel { Id = id }); + APIClient.Company = APIClient.GetRequest($"api/company/profile?id={APIClient.User?.CompanyId}"); + + return Redirect("~/Company/CompanyProfile"); + } + catch (Exception ex) + { + return RedirectToAction("Error", new { errorMessage = $"{ex.Message}", returnUrl }); } - - APIClient.PostRequest($"api/vacancy/delete", new VacancyBindingModel { Id = id }); - APIClient.Company = APIClient.GetRequest($"api/company/profile?id={APIClient.User?.CompanyId}"); - - return Redirect("~/Company/CompanyProfile"); } public IActionResult SearchVacancies(string? tags) { - if (APIClient.User == null) + string returnUrl = HttpContext.Request.Headers["Referer"].ToString(); + try { - throw new Exception("Доступно только авторизованным пользователям"); - } + if (APIClient.User == null) + { + throw new Exception("Доступно только авторизованным пользователям"); + } - if (string.IsNullOrEmpty(tags)) + if (string.IsNullOrEmpty(tags)) + { + ViewBag.Message = "Пожалуйста, введите поисковый запрос."; + return View(new List()); + } + + var results = APIClient.GetRequest>($"api/vacancy/search?tags={tags}"); + return View(results); + } + catch (Exception ex) { - ViewBag.Message = "Пожалуйста, введите поисковый запрос."; - return View(new List()); + return RedirectToAction("Error", new { errorMessage = $"{ex.Message}", returnUrl }); } - - var results = APIClient.GetRequest>($"api/vacancy/search?tags={tags}"); - return View(results); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/CandidateReviewClientApp/Views/Company/CompanyProfile.cshtml b/CandidateReviewClientApp/Views/Company/CompanyProfile.cshtml index 6f0dfd7..e3c830e 100644 --- a/CandidateReviewClientApp/Views/Company/CompanyProfile.cshtml +++ b/CandidateReviewClientApp/Views/Company/CompanyProfile.cshtml @@ -55,7 +55,7 @@ @if (Model.Vacancies != null && Model.Vacancies.Any()) {
- +
@@ -118,7 +118,7 @@ {
-
Название вакансии
+
diff --git a/CandidateReviewDatabaseImplement/Implements/ResumeStorage.cs b/CandidateReviewDatabaseImplement/Implements/ResumeStorage.cs index b0ee136..65df7bb 100644 --- a/CandidateReviewDatabaseImplement/Implements/ResumeStorage.cs +++ b/CandidateReviewDatabaseImplement/Implements/ResumeStorage.cs @@ -20,6 +20,13 @@ namespace CandidateReviewDatabaseImplement.Implements if (element != null) { + var assessmentsToRemove = context.Assessments + .Where(a => a.ResumeId == element.Id) + .ToList(); + if (assessmentsToRemove.Any()) + { + context.Assessments.RemoveRange(assessmentsToRemove); + } context.Resumes.Remove(element); context.SaveChanges(); diff --git a/CandidateReviewDatabaseImplement/Implements/VacancyStorage.cs b/CandidateReviewDatabaseImplement/Implements/VacancyStorage.cs index 0d6e972..72e7544 100644 --- a/CandidateReviewDatabaseImplement/Implements/VacancyStorage.cs +++ b/CandidateReviewDatabaseImplement/Implements/VacancyStorage.cs @@ -19,6 +19,21 @@ namespace CandidateReviewDatabaseImplement.Implements if (element != null) { + var resumesToRemove = context.Resumes.Where(a => a.VacancyId == element.Id).ToList(); + if (resumesToRemove.Any()) + { + foreach (var resume in resumesToRemove) + { + var assessmentsToRemove = context.Assessments + .Where(a => a.ResumeId == resume.Id) + .ToList(); + if (assessmentsToRemove.Any()) + { + context.Assessments.RemoveRange(assessmentsToRemove); + } + } + context.Resumes.RemoveRange(resumesToRemove); + } context.Vacancies.Remove(element); context.SaveChanges();
Фамилия