Готовые Аттестации

This commit is contained in:
DyCTaTOR 2024-05-29 22:48:30 +04:00
parent 85159ea8af
commit d6e5e9dced
4 changed files with 48 additions and 7 deletions

View File

@ -167,7 +167,7 @@ namespace UniversityClientAppWorker.Controllers
Response.Redirect("Attestations"); Response.Redirect("Attestations");
} }
[HttpGet] [HttpGet]
public async Task<IActionResult> InfoAttestation(int id) public IActionResult InfoAttestation(int id)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
@ -175,9 +175,49 @@ namespace UniversityClientAppWorker.Controllers
} }
ViewBag.Students = APIClient.GetRequest<List<StudentViewModel>>($"api/student/getstudents?userId={APIClient.User.Id}"); ViewBag.Students = APIClient.GetRequest<List<StudentViewModel>>($"api/student/getstudents?userId={APIClient.User.Id}");
ViewBag.AttestationScore = Enum.GetValues(typeof(AttestationScore)).Cast<AttestationScore>(); ViewBag.AttestationScore = Enum.GetValues(typeof(AttestationScore)).Cast<AttestationScore>();
var obj = await APIClient.GetRequestAsync<AttestationViewModel>($"api/attestation/getattestation?userId={APIClient.User.Id}&id={id}"); var obj = APIClient.GetRequest<AttestationViewModel>($"api/attestation/getattestation?userId={APIClient.User.Id}&id={id}");
return View(obj); return View(obj);
} }
[HttpPost]
public void UpdateAttestation(int id, string formOfEvaluation, int student, AttestationScore score)
{
if (APIClient.User == null)
{
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
}
if (string.IsNullOrEmpty(formOfEvaluation) || student == 0)
{
throw new Exception("Ââåäèòå ôîðìó îöåíèâàíèÿ è âûáåðèòå ñòóäåíòà");
}
var Student = APIClient.GetRequest<StudentViewModel>($"api/student/getstudent?userId={APIClient.User.Id}&studentId={student}");
if (Student == null)
{
throw new Exception("Ñòóäåíò íå íàéäåí");
}
APIClient.PostRequest("api/attestation/updateattestation", new AttestationBindingModel
{
Id = id,
FormOfEvaluation = formOfEvaluation,
StudentId = student,
StudentName = Student.Name,
Score = score
});
Response.Redirect("Attestations");
}
[HttpPost]
public void DeleteAttestation(int id)
{
if (id == 0)
{
throw new Exception("id íå ìîæåò áûòü ðàâåí 0");
}
APIClient.PostRequest("api/attestation/deleteattestation", new PlanOfStudyBindingModel
{
Id = id
});
Response.Redirect("Attestations");
}
[HttpGet] [HttpGet]
public async Task<IActionResult> Students() public async Task<IActionResult> Students()
{ {

View File

@ -1,10 +1,10 @@
@using UniversityContracts.ViewModels @using UniversityContracts.ViewModels
@model AttestationViewModel @model AttestationViewModel
@{ @{
ViewData["Title"] = "Аттестация"; ViewData["Title"] = "План обучения";
} }
<div class="text-center"> <div class="text-center">
<h2 class="display-4">Аттестация</h2> <h2 class="display-4">@ViewData["Title"]</h2>
</div> </div>
<form asp-action="UpdateAttestation" method="post"> <form asp-action="UpdateAttestation" method="post">
<div class="row"> <div class="row">
@ -26,12 +26,13 @@
<div class="row"> <div class="row">
<div class="col-4">Оценка:</div> <div class="col-4">Оценка:</div>
<div class="col-8"> <div class="col-8">
<select id="score" name="score" class="form-control" asp-items="@(new SelectList(ViewBag.AttestationScore, "Score", Model.Score.ToString() ?? ""))"></select> <select id="score" name="score" class="form-control" asp-items="@(new SelectList(ViewBag.AttestationScore, "Score"))"></select>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-8"></div> <div class="col-8"></div>
<div class="col-4 mt-2"> <div class="col-4 mt-2">
<input type="hidden" name="id" value="@Model.Id" />
<input type="submit" value="Сохранить" class="btn btn-primary" /> <input type="submit" value="Сохранить" class="btn btn-primary" />
</div> </div>
</div> </div>

View File

@ -4,7 +4,7 @@
ViewData["Title"] = "План обучения"; ViewData["Title"] = "План обучения";
} }
<div class="text-center"> <div class="text-center">
<h2 class="display-4">План обучения</h2> <h2 class="display-4">@ViewData["Title"]</h2>
</div> </div>
<form asp-action="UpdatePlanOfStudy" method="post"> <form asp-action="UpdatePlanOfStudy" method="post">
<div class="row"> <div class="row">

View File

@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR //Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR
optionsBuilder.UseSqlServer(@"Data Source=DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }