поиск вакансий, вывод сотрудников и добавление сотрудников, новая роль Администратор, мелкие правки
This commit is contained in:
@@ -22,11 +22,6 @@ namespace CandidateReviewUserApp.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
@@ -41,14 +36,15 @@ namespace CandidateReviewUserApp.Controllers
|
||||
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
APIClient.User = APIClient.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}");
|
||||
if (APIClient.User.CompanyId != null)
|
||||
{
|
||||
APIClient.Company = APIClient.GetRequest<CompanyViewModel>($"api/company/profile?id={APIClient.User?.CompanyId}");
|
||||
}
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
if (APIClient.User?.CompanyId != null)
|
||||
{
|
||||
APIClient.Company = APIClient.GetRequest<CompanyViewModel>($"api/company/profile?id={APIClient.User?.CompanyId}");
|
||||
}
|
||||
|
||||
Response.Redirect("/Home/Index");
|
||||
}
|
||||
|
||||
@@ -70,7 +66,7 @@ namespace CandidateReviewUserApp.Controllers
|
||||
|
||||
if (login.Equals("tania.art03@gmail.com", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
role = RoleEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
role = RoleEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
}
|
||||
else if (login.Equals("t.artamonova73@icloud.com", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace CandidateReviewClientApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult UserProfile(int? id)
|
||||
{
|
||||
var userId = id ?? APIClient.User.Id;
|
||||
var userId = id ?? APIClient.User?.Id;
|
||||
|
||||
var model = APIClient.GetRequest<UserViewModel>($"api/user/profile?id={userId}");
|
||||
|
||||
@@ -31,41 +31,79 @@ namespace CandidateReviewClientApp.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult UserProfileEdit()
|
||||
public IActionResult UserProfileEdit(int? id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("/Home/Enter");
|
||||
}
|
||||
var model = APIClient.GetRequest<UserViewModel?>($"api/user/profile?id={APIClient.User.Id}");
|
||||
if (model == null)
|
||||
|
||||
if (APIClient.Company == null)
|
||||
{
|
||||
return RedirectToAction("/Home/Index");
|
||||
return Redirect("/Home/Index");
|
||||
}
|
||||
return View(model);
|
||||
|
||||
if (!id.HasValue)
|
||||
{
|
||||
return View(new UserViewModel());
|
||||
}
|
||||
else if (id.HasValue)
|
||||
{
|
||||
var employee = APIClient.GetRequest<UserViewModel?>($"api/user/profile?id={id}");
|
||||
return View(employee);
|
||||
}
|
||||
else
|
||||
{
|
||||
var model = APIClient.GetRequest<UserViewModel?>($"api/user/profile?id={APIClient.User.Id}");
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UserProfileEdit(UserBindingModel model)
|
||||
{
|
||||
APIClient.PostRequest("api/user/update", new UserBindingModel
|
||||
if (model.Id != 0)
|
||||
{
|
||||
Id = model.Id,
|
||||
Surname = model.Surname,
|
||||
Name = model.Name,
|
||||
LastName = model.LastName,
|
||||
CompanyId = model.CompanyId,
|
||||
Email = model.Email,
|
||||
Password = model.Password,
|
||||
EmailConfirmed = model.EmailConfirmed,
|
||||
Role = model.Role,
|
||||
AvatarFilePath = model.AvatarFilePath,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
});
|
||||
APIClient.PostRequest("api/user/update", model);
|
||||
}
|
||||
else
|
||||
{
|
||||
APIClient.PostRequest("api/user/register", model);
|
||||
if (APIClient.Company != null)
|
||||
{
|
||||
APIClient.Company?.Employees.Add(new UserViewModel
|
||||
{
|
||||
Id = model.Id,
|
||||
Surname = model.Surname,
|
||||
Name = model.Name,
|
||||
LastName = model.LastName,
|
||||
CompanyId = model.CompanyId,
|
||||
Email = model.Email,
|
||||
Password = model.Password,
|
||||
EmailConfirmed = model.EmailConfirmed,
|
||||
Role = CandidateReviewDataModels.Enums.RoleEnum.Сотрудник,
|
||||
AvatarFilePath = model.AvatarFilePath,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
});
|
||||
}
|
||||
Response.Redirect($"/Company/CompanyProfile/{model.CompanyId}");
|
||||
return;
|
||||
}
|
||||
|
||||
Response.Redirect($"/User/UserProfile/{model.Id}");
|
||||
}
|
||||
|
||||
public IActionResult DeleteEmployee(int id)
|
||||
{
|
||||
APIClient.PostRequest("api/user/delete", new UserBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
APIClient.Company = APIClient.GetRequest<CompanyViewModel?>($"api/company/profile?id={APIClient.User?.CompanyId}");
|
||||
|
||||
return Redirect($"~/Company/CompanyProfile");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public void Logout()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using CandidateReviewContracts.BindingModels;
|
||||
using CandidateReviewContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Reflection;
|
||||
|
||||
namespace CandidateReviewClientApp.Controllers
|
||||
{
|
||||
@@ -13,7 +14,7 @@ namespace CandidateReviewClientApp.Controllers
|
||||
_logger = logger;
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Vacancy(int? id)
|
||||
public IActionResult VacancyDetails(int? id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
@@ -42,6 +43,7 @@ namespace CandidateReviewClientApp.Controllers
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HttpPost]
|
||||
public void EditVacancy(VacancyBindingModel model)
|
||||
{
|
||||
@@ -49,6 +51,12 @@ namespace CandidateReviewClientApp.Controllers
|
||||
{
|
||||
throw new Exception("Доступно только авторизованным пользователям");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.Tags))
|
||||
{
|
||||
model.Tags = model.Tags.ToLowerInvariant();
|
||||
}
|
||||
|
||||
if (model.Id != 0)
|
||||
{
|
||||
APIClient.PostRequest("api/vacancy/update", model);
|
||||
@@ -58,11 +66,16 @@ namespace CandidateReviewClientApp.Controllers
|
||||
APIClient.PostRequest("api/vacancy/create", model);
|
||||
if (APIClient.Company != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.Tags))
|
||||
{
|
||||
model.Tags = model.Tags.ToLowerInvariant();
|
||||
}
|
||||
|
||||
APIClient.Company?.Vacancies.Add(new VacancyViewModel
|
||||
{
|
||||
Id = model.Id,
|
||||
CompanyId = model.CompanyId,
|
||||
CreatedAt = model.CreatedAt,
|
||||
CreatedAt = DateTime.Now.ToUniversalTime(),
|
||||
Description = model.Description,
|
||||
JobTitle = model.JobTitle,
|
||||
JobType = model.JobType,
|
||||
@@ -72,21 +85,39 @@ namespace CandidateReviewClientApp.Controllers
|
||||
Status = model.Status,
|
||||
Tags = model.Tags
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Response.Redirect($"/Company/CompanyProfile/{model.CompanyId}");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(int id)
|
||||
public IActionResult Delete(int id)
|
||||
{
|
||||
if (APIClient.Company == null)
|
||||
{
|
||||
throw new Exception("Компания не определена");
|
||||
}
|
||||
|
||||
APIClient.PostRequest($"api/vacancy/delete", new VacancyBindingModel { Id = id });
|
||||
APIClient.Company = APIClient.GetRequest<CompanyViewModel?>($"api/company/profile?id={APIClient.User?.CompanyId}");
|
||||
|
||||
return Redirect("~/Company/CompanyProfile");
|
||||
}
|
||||
|
||||
public IActionResult SearchVacancies(string? tags)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Доступно только авторизованным пользователям");
|
||||
}
|
||||
|
||||
APIClient.PostRequest($"api/vacancy/delete", new VacancyBindingModel { Id = id });
|
||||
Response.Redirect("/Home/Index");
|
||||
if (string.IsNullOrEmpty(tags))
|
||||
{
|
||||
ViewBag.Message = "Пожалуйста, введите поисковый запрос.";
|
||||
return View(new List<VacancyViewModel?>());
|
||||
}
|
||||
|
||||
var results = APIClient.GetRequest<List<VacancyViewModel?>>($"api/vacancy/search?tags={tags}");
|
||||
return View(results);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user