Промежуточное
This commit is contained in:
parent
478fbf8b8a
commit
85159ea8af
@ -1,3 +1,4 @@
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PlumbingRepairClientApp;
|
||||
using System.Diagnostics;
|
||||
@ -149,15 +150,34 @@ namespace UniversityClientAppWorker.Controllers
|
||||
{
|
||||
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/createattestation", new AttestationBindingModel
|
||||
{
|
||||
UserId = APIClient.User.Id,
|
||||
FormOfEvaluation = formOfEvaluation,
|
||||
StudentId = student,
|
||||
StudentName = Student.Name,
|
||||
Score = score
|
||||
});
|
||||
Response.Redirect("Attestations");
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> InfoAttestation(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Students = APIClient.GetRequest<List<StudentViewModel>>($"api/student/getstudents?userId={APIClient.User.Id}");
|
||||
ViewBag.AttestationScore = Enum.GetValues(typeof(AttestationScore)).Cast<AttestationScore>();
|
||||
var obj = await APIClient.GetRequestAsync<AttestationViewModel>($"api/attestation/getattestation?userId={APIClient.User.Id}&id={id}");
|
||||
return View(obj);
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Students()
|
||||
{
|
||||
|
@ -67,7 +67,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a asp-controller="Home" asp-action="" asp-route-id="@attestation.Id" class="btn btn-warning">Изменить</a>
|
||||
<a asp-controller="Home" asp-action="InfoAttestation" asp-route-id="@attestation.Id" class="btn btn-warning">Изменить</a>
|
||||
<form asp-controller="Home" asp-action="DeleteAttestation" method="post">
|
||||
<input type="hidden" name="id" value="@attestation.Id" />
|
||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||
|
@ -0,0 +1,38 @@
|
||||
@using UniversityContracts.ViewModels
|
||||
@model AttestationViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Аттестация";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Аттестация</h2>
|
||||
</div>
|
||||
<form asp-action="UpdateAttestation" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Форма оценивания:</div>
|
||||
<div class="col-8">
|
||||
<select name="formOfEvaluation" id="formOfEvaluation" class="form-control" value="@Model.FormOfEvaluation">
|
||||
<option value="Зачёт">Зачёт</option>
|
||||
<option value="Экзамен">Экзамен</option>
|
||||
<option value="Дифферинцируемый зачёт">Дифферинцируемый зачёт</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Студент:</div>
|
||||
<div class="col-8">
|
||||
<select name="student" id="student" class="form-control" asp-items="@(new SelectList(ViewBag.Students, "Id", "Name", Model.StudentId))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Оценка:</div>
|
||||
<div class="col-8">
|
||||
<select id="score" name="score" class="form-control" asp-items="@(new SelectList(ViewBag.AttestationScore, "Score", Model.Score.ToString() ?? ""))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4 mt-2">
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -12,6 +12,7 @@ namespace UniversityContracts.BusinessLogicsContracts
|
||||
public interface IAttestationLogic
|
||||
{
|
||||
List<AttestationViewModel>? ReadList(AttestationSearchModel? model);
|
||||
AttestationViewModel? ReadElement(AttestationSearchModel model);
|
||||
bool CreateAttestation(AttestationBindingModel model);
|
||||
bool DeleteAttestation(AttestationBindingModel model);
|
||||
bool UpdateAttestation(AttestationBindingModel model);
|
||||
|
@ -5,7 +5,6 @@ namespace UniversityDataModels.Models
|
||||
public interface IAttestationModel : IId
|
||||
{
|
||||
int UserId { get; }
|
||||
string StudentName { get; }
|
||||
string FormOfEvaluation { get; }
|
||||
AttestationScore Score { get; }
|
||||
int StudentId { get; }
|
||||
|
@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR
|
||||
optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -32,6 +32,19 @@ namespace UniversityRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public AttestationViewModel? GetAttestation(int userId, int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new AttestationSearchModel { UserId = userId, Id = id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения аттестаций пользователя id={Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateAttestation(AttestationBindingModel model)
|
||||
{
|
||||
@ -44,7 +57,7 @@ namespace UniversityRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
[HttpPost]
|
||||
public void UpdateAttestation(AttestationBindingModel model)
|
||||
{
|
||||
try
|
||||
@ -57,7 +70,7 @@ namespace UniversityRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
[HttpPost]
|
||||
public void DeleteAttestation(AttestationBindingModel model)
|
||||
{
|
||||
try
|
||||
|
@ -30,6 +30,19 @@ namespace UniversityRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public StudentViewModel? GetStudent(int userId, int studentId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new StudentSearchModel { UserId = userId, Id = studentId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка студентов пользователя id={Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateStudent(StudentBindingModel model)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user