This commit is contained in:
GokaPek 2024-05-30 04:16:45 +04:00
commit e85ff82d03
4 changed files with 430 additions and 430 deletions

View File

@ -10,7 +10,7 @@ namespace UniversityBusinessLogic.OfficePackage
CreatePdf(info); CreatePdf(info);
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "4 cm" }); CreateTable(new List<string> { "6cm", "6cm", "6cm", "3cm", "4 cm" });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {

View File

@ -197,8 +197,8 @@ namespace UniversityClientApp.Controllers
{ {
APIStorekeeper.PostRequest("api/teacher/loadreporttoword", new ReportBindingModel APIStorekeeper.PostRequest("api/teacher/loadreporttoword", new ReportBindingModel
{ {
FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\TeachersAndStudents.docx" FileName = $"C:\\ÂðåìåííûåÎò÷¸òû\\TeachersAndStudents.docx"
}); });
return GetWordFile(); return GetWordFile();
} }
@ -206,7 +206,7 @@ namespace UniversityClientApp.Controllers
{ {
APIStorekeeper.PostRequest("api/teacher/loadreporttoexcel", new ReportBindingModel APIStorekeeper.PostRequest("api/teacher/loadreporttoexcel", new ReportBindingModel
{ {
FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\TeachersAndStudents.xlsx" FileName = $"C:\\ÂðåìåííûåÎò÷¸òû\\TeachersAndStudents.xlsx"
}); });
return GetExcelFile(); return GetExcelFile();
} }

View File

@ -1,461 +1,461 @@
using DocumentFormat.OpenXml.Office2010.Excel; using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Wordprocessing; using DocumentFormat.OpenXml.Wordprocessing;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using PlumbingRepairClientApp; using PlumbingRepairClientApp;
using System.Diagnostics; using System.Diagnostics;
using UniversityClientAppWorker.Models; using UniversityClientAppWorker.Models;
using UniversityContracts.BindingModels; using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels; using UniversityContracts.ViewModels;
using UniversityDatabaseImplement.Models; using UniversityDatabaseImplement.Models;
using UniversityDataModels.Enums; using UniversityDataModels.Enums;
using UniversityDataModels.Models; using UniversityDataModels.Models;
using static System.Runtime.InteropServices.JavaScript.JSType; using static System.Runtime.InteropServices.JavaScript.JSType;
namespace UniversityClientAppWorker.Controllers namespace UniversityClientAppWorker.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger) public HomeController(ILogger<HomeController> logger)
{ {
_logger = logger; _logger = logger;
} }
[HttpGet] [HttpGet]
public async Task<IActionResult> Index() public async Task<IActionResult> Index()
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
ViewBag.Teachers = APIClient.GetRequest<List<TeacherViewModel>>($"api/teacher/getallteachers"); ViewBag.Teachers = APIClient.GetRequest<List<TeacherViewModel>>($"api/teacher/getallteachers");
var planOfStudys = await APIClient.GetRequestPlanOfStudyAsync<List<PlanOfStudyViewModel>>($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}"); var planOfStudys = await APIClient.GetRequestPlanOfStudyAsync<List<PlanOfStudyViewModel>>($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}");
return View(planOfStudys); return View(planOfStudys);
} }
[HttpGet] [HttpGet]
public async Task<IActionResult> InfoPlanOfStudy(int id) public async Task<IActionResult> InfoPlanOfStudy(int id)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
var obj1 = APIClient.GetRequest<List<TeacherViewModel>>($"api/teacher/getallteachers"); var obj1 = APIClient.GetRequest<List<TeacherViewModel>>($"api/teacher/getallteachers");
ViewBag.Teachers = obj1; ViewBag.Teachers = obj1;
var obj = await APIClient.GetRequestPlanOfStudyAsync<PlanOfStudyViewModel>($"api/planofstudys/getplanofstudy?id={id}&userId={APIClient.User.Id}"); var obj = await APIClient.GetRequestPlanOfStudyAsync<PlanOfStudyViewModel>($"api/planofstudys/getplanofstudy?id={id}&userId={APIClient.User.Id}");
return View(obj); return View(obj);
} }
[HttpPost] [HttpPost]
public void CreatePlanOfStudy(string profile, string formOfStudy, List<int> teacherIds) public void CreatePlanOfStudy(string profile, string formOfStudy, List<int> teacherIds)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì ïîëüçîâàòåëÿì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì ïîëüçîâàòåëÿì");
} }
if (string.IsNullOrEmpty(formOfStudy) || string.IsNullOrEmpty(profile)) if (string.IsNullOrEmpty(formOfStudy) || string.IsNullOrEmpty(profile))
{ {
throw new Exception("Ââåäèòå äàííûå ïðîôèëÿ è ôîðìû îáó÷åíèÿ"); throw new Exception("Ââåäèòå äàííûå ïðîôèëÿ è ôîðìû îáó÷åíèÿ");
} }
APIClient.PostRequest("api/planofstudys/createplanofstudy", new PlanOfStudyBindingModel APIClient.PostRequest("api/planofstudys/createplanofstudy", new PlanOfStudyBindingModel
{ {
Profile = profile, Profile = profile,
FormOfStudy = formOfStudy, FormOfStudy = formOfStudy,
UserId = APIClient.User.Id, UserId = APIClient.User.Id,
PlanOfStudyTeachers = teacherIds.ToDictionary(id => id, id => (ITeacherModel)null) PlanOfStudyTeachers = teacherIds.ToDictionary(id => id, id => (ITeacherModel)null)
}); });
Response.Redirect("Index"); Response.Redirect("Index");
} }
[HttpPost] [HttpPost]
public void DeletePlanOfStudy(int id) public void DeletePlanOfStudy(int id)
{ {
if (id == 0) if (id == 0)
{ {
throw new Exception("id íå ìîæåò áûòü ðàâåí 0"); throw new Exception("id íå ìîæåò áûòü ðàâåí 0");
} }
APIClient.PostRequest("api/planofstudys/deleteplanofstudy", new PlanOfStudyBindingModel APIClient.PostRequest("api/planofstudys/deleteplanofstudy", new PlanOfStudyBindingModel
{ {
Id = id Id = id
}); });
Response.Redirect("Index"); Response.Redirect("Index");
} }
[HttpPost] [HttpPost]
public void UpdatePlanOfStudy(int id, string profile, string formOfStudy, List<int> teacherIds) public void UpdatePlanOfStudy(int id, string profile, string formOfStudy, List<int> teacherIds)
{ {
if (id == 0) if (id == 0)
{ {
throw new Exception("id íå ìîæåò áûòü ðàâåí 0"); throw new Exception("id íå ìîæåò áûòü ðàâåí 0");
} }
var planOfStudyTeachers = teacherIds.ToDictionary(id => id, id => (ITeacherModel)null); var planOfStudyTeachers = teacherIds.ToDictionary(id => id, id => (ITeacherModel)null);
APIClient.PostRequest("api/planofstudys/updateplanofstudy", new PlanOfStudyBindingModel APIClient.PostRequest("api/planofstudys/updateplanofstudy", new PlanOfStudyBindingModel
{ {
Id = id, Id = id,
Profile = profile, Profile = profile,
FormOfStudy = formOfStudy, FormOfStudy = formOfStudy,
PlanOfStudyTeachers = planOfStudyTeachers PlanOfStudyTeachers = planOfStudyTeachers
}); });
Response.Redirect("Index"); Response.Redirect("Index");
} }
[HttpGet] [HttpGet]
public IActionResult Privacy() public IActionResult Privacy()
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(APIClient.User); return View(APIClient.User);
} }
[HttpPost] [HttpPost]
public void Privacy(string login, string password, string email) public void Privacy(string login, string password, string email)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì ïîëüçîâàòåëÿì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì ïîëüçîâàòåëÿì");
} }
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email)) if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
{ {
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ïî÷òó"); throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ïî÷òó");
} }
APIClient.PostRequest("api/user/updatedata", new UserViewModel APIClient.PostRequest("api/user/updatedata", new UserViewModel
{ {
Id = APIClient.User.Id, Id = APIClient.User.Id,
Email = email, Email = email,
Login = login, Login = login,
Password = password Password = password
}); });
APIClient.User.Login = login; APIClient.User.Login = login;
APIClient.User.Email = email; APIClient.User.Email = email;
APIClient.User.Password = password; APIClient.User.Password = password;
Response.Redirect("Index"); Response.Redirect("Index");
} }
[HttpGet] [HttpGet]
public IActionResult Attestations() public IActionResult Attestations()
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
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 = APIClient.GetRequest<List<AttestationViewModel>>($"api/attestation/getattestations?userId={APIClient.User.Id}"); var obj = APIClient.GetRequest<List<AttestationViewModel>>($"api/attestation/getattestations?userId={APIClient.User.Id}");
return View(obj); return View(obj);
} }
[HttpPost] [HttpPost]
public void CreateAttestation(string formOfEvaluation, int student, AttestationScore score) public void CreateAttestation(string formOfEvaluation, int student, AttestationScore score)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
} }
if (string.IsNullOrEmpty(formOfEvaluation) || student == 0) if (string.IsNullOrEmpty(formOfEvaluation) || student == 0)
{ {
throw new Exception("Ââåäèòå ôîðìó îöåíèâàíèÿ è âûáåðèòå ñòóäåíòà"); throw new Exception("Ââåäèòå ôîðìó îöåíèâàíèÿ è âûáåðèòå ñòóäåíòà");
} }
var Student = APIClient.GetRequest<StudentViewModel>($"api/student/getstudent?userId={APIClient.User.Id}&studentId={student}"); var Student = APIClient.GetRequest<StudentViewModel>($"api/student/getstudent?userId={APIClient.User.Id}&studentId={student}");
if(Student == null) if(Student == null)
{ {
throw new Exception("Ñòóäåíò íå íàéäåí"); throw new Exception("Ñòóäåíò íå íàéäåí");
} }
APIClient.PostRequest("api/attestation/createattestation", new AttestationBindingModel APIClient.PostRequest("api/attestation/createattestation", new AttestationBindingModel
{ {
UserId = APIClient.User.Id, UserId = APIClient.User.Id,
FormOfEvaluation = formOfEvaluation, FormOfEvaluation = formOfEvaluation,
StudentId = student, StudentId = student,
StudentName = Student.Name, StudentName = Student.Name,
Score = score Score = score
}); });
Response.Redirect("Attestations"); Response.Redirect("Attestations");
} }
[HttpGet] [HttpGet]
public IActionResult InfoAttestation(int id) public IActionResult InfoAttestation(int id)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
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 = APIClient.GetRequest<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] [HttpPost]
public void UpdateAttestation(int id, string formOfEvaluation, int student, AttestationScore score) public void UpdateAttestation(int id, string formOfEvaluation, int student, AttestationScore score)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
} }
if (string.IsNullOrEmpty(formOfEvaluation) || student == 0) if (string.IsNullOrEmpty(formOfEvaluation) || student == 0)
{ {
throw new Exception("Ââåäèòå ôîðìó îöåíèâàíèÿ è âûáåðèòå ñòóäåíòà"); throw new Exception("Ââåäèòå ôîðìó îöåíèâàíèÿ è âûáåðèòå ñòóäåíòà");
} }
var Student = APIClient.GetRequest<StudentViewModel>($"api/student/getstudent?userId={APIClient.User.Id}&studentId={student}"); var Student = APIClient.GetRequest<StudentViewModel>($"api/student/getstudent?userId={APIClient.User.Id}&studentId={student}");
if (Student == null) if (Student == null)
{ {
throw new Exception("Ñòóäåíò íå íàéäåí"); throw new Exception("Ñòóäåíò íå íàéäåí");
} }
APIClient.PostRequest("api/attestation/updateattestation", new AttestationBindingModel APIClient.PostRequest("api/attestation/updateattestation", new AttestationBindingModel
{ {
Id = id, Id = id,
FormOfEvaluation = formOfEvaluation, FormOfEvaluation = formOfEvaluation,
StudentId = student, StudentId = student,
StudentName = Student.Name, StudentName = Student.Name,
Score = score Score = score
}); });
Response.Redirect("Attestations"); Response.Redirect("Attestations");
} }
[HttpPost] [HttpPost]
public void DeleteAttestation(int id) public void DeleteAttestation(int id)
{ {
if (id == 0) if (id == 0)
{ {
throw new Exception("id íå ìîæåò áûòü ðàâåí 0"); throw new Exception("id íå ìîæåò áûòü ðàâåí 0");
} }
APIClient.PostRequest("api/attestation/deleteattestation", new PlanOfStudyBindingModel APIClient.PostRequest("api/attestation/deleteattestation", new PlanOfStudyBindingModel
{ {
Id = id Id = id
}); });
Response.Redirect("Attestations"); Response.Redirect("Attestations");
} }
[HttpGet] [HttpGet]
public async Task<IActionResult> Students() public async Task<IActionResult> Students()
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
var planOfStudys = await APIClient.GetRequestPlanOfStudyAsync<List<PlanOfStudyViewModel>> var planOfStudys = await APIClient.GetRequestPlanOfStudyAsync<List<PlanOfStudyViewModel>>
($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}"); ($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}");
ViewBag.PlanOfStudys = planOfStudys; ViewBag.PlanOfStudys = planOfStudys;
return View(APIClient.GetRequest<List<StudentViewModel>>($"api/student/getstudents?userId={APIClient.User.Id}")); return View(APIClient.GetRequest<List<StudentViewModel>>($"api/student/getstudents?userId={APIClient.User.Id}"));
} }
[HttpPost] [HttpPost]
public async Task<IActionResult> CreateStudent(string name, int planOfStudy, string phoneNumber) public async Task<IActionResult> CreateStudent(string name, int planOfStudy, string phoneNumber)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
} }
if (string.IsNullOrEmpty(name) || planOfStudy == 0 || string.IsNullOrEmpty(phoneNumber)) if (string.IsNullOrEmpty(name) || planOfStudy == 0 || string.IsNullOrEmpty(phoneNumber))
{ {
throw new Exception("Ââåäèòå ÔÈÎ, ïëàí îáó÷åíèÿ è òåëåôîí"); throw new Exception("Ââåäèòå ÔÈÎ, ïëàí îáó÷åíèÿ è òåëåôîí");
} }
var PlanOfStudy = await APIClient.GetRequestPlanOfStudyAsync<PlanOfStudyViewModel>($"api/planofstudys/getplanofstudy?id={planOfStudy}"); var PlanOfStudy = await APIClient.GetRequestPlanOfStudyAsync<PlanOfStudyViewModel>($"api/planofstudys/getplanofstudy?id={planOfStudy}");
if(PlanOfStudy == null) if(PlanOfStudy == null)
{ {
throw new Exception("Ïëàí îáó÷åíèÿ íå íàéäåí"); throw new Exception("Ïëàí îáó÷åíèÿ íå íàéäåí");
} }
APIClient.PostRequest("api/student/createstudent", new StudentBindingModel APIClient.PostRequest("api/student/createstudent", new StudentBindingModel
{ {
UserId = APIClient.User.Id, UserId = APIClient.User.Id,
Name = name, Name = name,
PlanOfStudyId = planOfStudy, PlanOfStudyId = planOfStudy,
PlanOfStudyProfile = PlanOfStudy.Profile, PlanOfStudyProfile = PlanOfStudy.Profile,
PhoneNumber = phoneNumber, PhoneNumber = phoneNumber,
}); });
return Redirect("/Home/Students"); return Redirect("/Home/Students");
} }
[HttpGet] [HttpGet]
public async Task<IActionResult> InfoStudent(int id) public async Task<IActionResult> InfoStudent(int id)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
if(id == 0) if(id == 0)
{ {
throw new Exception("id íå ìîæåò áûòü 0"); throw new Exception("id íå ìîæåò áûòü 0");
} }
var planOfStudys = await APIClient.GetRequestPlanOfStudyAsync<List<PlanOfStudyViewModel>> var planOfStudys = await APIClient.GetRequestPlanOfStudyAsync<List<PlanOfStudyViewModel>>
($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}"); ($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}");
ViewBag.PlanOfStudys = planOfStudys; ViewBag.PlanOfStudys = planOfStudys;
var obj = APIClient.GetRequest<StudentViewModel>($"api/student/getstudent?userId={APIClient.User.Id}&studentId={id}"); var obj = APIClient.GetRequest<StudentViewModel>($"api/student/getstudent?userId={APIClient.User.Id}&studentId={id}");
return View(obj); return View(obj);
} }
[HttpPost] [HttpPost]
public async Task<IActionResult> UpdateStudent(int id, string name, int planOfStudy, string phoneNumber) public async Task<IActionResult> UpdateStudent(int id, string name, int planOfStudy, string phoneNumber)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
} }
if(id == 0) if(id == 0)
{ {
throw new Exception("id íå ìîæåò áûòü 0"); throw new Exception("id íå ìîæåò áûòü 0");
}
if (string.IsNullOrEmpty(name) || planOfStudy == 0 || string.IsNullOrEmpty(phoneNumber))
{
throw new Exception("Ââåäèòå ÔÈÎ, ïëàí îáó÷åíèÿ è òåëåôîí");
} }
if (string.IsNullOrEmpty(name) || planOfStudy == 0 || string.IsNullOrEmpty(phoneNumber)) var PlanOfStudy = await APIClient.GetRequestPlanOfStudyAsync<PlanOfStudyViewModel>($"api/planofstudys/getplanofstudy?id={planOfStudy}");
{
throw new Exception("Ââåäèòå ÔÈÎ, ïëàí îáó÷åíèÿ è òåëåôîí");
}
var PlanOfStudy = await APIClient.GetRequestPlanOfStudyAsync<PlanOfStudyViewModel>($"api/planofstudys/getplanofstudy?id={planOfStudy}");
if (PlanOfStudy == null) if (PlanOfStudy == null)
{ {
throw new Exception("Ïëàí îáó÷åíèÿ íå íàéäåí"); throw new Exception("Ïëàí îáó÷åíèÿ íå íàéäåí");
} }
APIClient.PostRequest("api/student/updatestudent", new StudentBindingModel APIClient.PostRequest("api/student/updatestudent", new StudentBindingModel
{ {
Id = id, Id = id,
Name = name, Name = name,
PlanOfStudyId = planOfStudy, PlanOfStudyId = planOfStudy,
PlanOfStudyProfile = PlanOfStudy.Profile, PlanOfStudyProfile = PlanOfStudy.Profile,
PhoneNumber = phoneNumber, PhoneNumber = phoneNumber,
}); });
return Redirect("/Home/Students"); return Redirect("/Home/Students");
} }
[HttpPost] [HttpPost]
public void DeleteStudent(int id) public void DeleteStudent(int id)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
} }
if (id == 0) if (id == 0)
{ {
throw new Exception("id íå ìîæåò áûòü 0"); throw new Exception("id íå ìîæåò áûòü 0");
} }
APIClient.PostRequest("api/student/deletestudent", new StudentBindingModel APIClient.PostRequest("api/student/deletestudent", new StudentBindingModel
{ {
Id = id Id = id
}); });
Response.Redirect("Students"); Response.Redirect("Students");
} }
[HttpGet] [HttpGet]
public IActionResult Enter() public IActionResult Enter()
{ {
return View(); return View();
} }
[HttpGet] [HttpGet]
public IActionResult Register() public IActionResult Register()
{ {
return View(); return View();
} }
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() public IActionResult Error()
{ {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
} }
[HttpPost] [HttpPost]
public void Enter(string login, string password) public void Enter(string login, string password)
{ {
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{ {
throw new Exception("Ââåäèòå ëîãèí è ïàðîëü"); throw new Exception("Ââåäèòå ëîãèí è ïàðîëü");
} }
APIClient.User = APIClient.GetRequest<UserViewModel>($"api/user/loginworker?login={login}&password={password}"); APIClient.User = APIClient.GetRequest<UserViewModel>($"api/user/loginworker?login={login}&password={password}");
if (APIClient.User == null) if (APIClient.User == null)
{ {
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü"); throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
} }
Response.Redirect("Index"); Response.Redirect("Index");
} }
[HttpPost] [HttpPost]
public void Register(string login, string password, string email) public void Register(string login, string password, string email)
{ {
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email)) if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
{ {
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ïî÷òó"); throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ïî÷òó");
} }
APIClient.PostRequest("api/user/registerworker", new UserBindingModel APIClient.PostRequest("api/user/registerworker", new UserBindingModel
{ {
Email = email, Email = email,
Login = login, Login = login,
Password = password Password = password
}); });
Response.Redirect("Enter"); Response.Redirect("Enter");
return; return;
} }
[HttpGet] [HttpGet]
public IActionResult GetWordFile() public IActionResult GetWordFile()
{ {
return PhysicalFile($"C:\\Users\\{Environment.UserName}\\Downloads\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.docx", return PhysicalFile($"C:\\ÂðåìåííûåÎò÷¸òû\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.docx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.docx"); "Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.docx");
} }
public IActionResult GetExcelFile() public IActionResult GetExcelFile()
{ {
return PhysicalFile($"C:\\Users\\{Environment.UserName}\\Downloads\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.xlsx", return PhysicalFile($"C:\\ÂðåìåííûåÎò÷¸òû\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.xlsx",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.xlsx"); "Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.xlsx");
} }
[HttpGet] [HttpGet]
public IActionResult ReportPlanOfStudys() public IActionResult ReportPlanOfStudys()
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View("ReportPlanOfStudys", APIClient.GetRequest<List<ReportPlanOfStudyViewModel>>($"api/planofstudys/getplanofstudyanddisciplines?userId={APIClient.User.Id}")); return View("ReportPlanOfStudys", APIClient.GetRequest<List<ReportPlanOfStudyViewModel>>($"api/planofstudys/getplanofstudyanddisciplines?userId={APIClient.User.Id}"));
} }
[HttpPost] [HttpPost]
public IActionResult ReportPlanOfStudys(string type) public IActionResult ReportPlanOfStudys(string type)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
Redirect("~/Home/Enter"); Redirect("~/Home/Enter");
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
} }
if (string.IsNullOrEmpty(type)) if (string.IsNullOrEmpty(type))
{ {
throw new Exception("Íåâåðíûé òèï îò÷åòà"); throw new Exception("Íåâåðíûé òèï îò÷åòà");
} }
if (type == "docx") if (type == "docx")
{ {
APIClient.PostRequest("api/planofstudys/loadreporttoword", new ReportBindingModel APIClient.PostRequest("api/planofstudys/loadreporttoword", new ReportBindingModel
{ {
FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.docx" FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.docx"
}); });
return GetWordFile(); return GetWordFile();
} }
if (type == "xlsx") if (type == "xlsx")
{ {
APIClient.PostRequest("api/planofstudys/loadreporttoexcel", new ReportBindingModel APIClient.PostRequest("api/planofstudys/loadreporttoexcel", new ReportBindingModel
{ {
FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.xlsx" FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.xlsx"
}); });
return GetExcelFile(); return GetExcelFile();
} }
return Redirect("Index"); return Redirect("Index");
} }
[HttpGet] [HttpGet]
public IActionResult ReportPlanOfStudyAndStudents() public IActionResult ReportPlanOfStudyAndStudents()
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View("ReportPlanOfStudyAndStudents", APIClient.GetRequest<List<ReportPlanOfStudyAndStudentViewModel>>($"api/planofstudys/getplanofstudyandstudents")); return View("ReportPlanOfStudyAndStudents", APIClient.GetRequest<List<ReportPlanOfStudyAndStudentViewModel>>($"api/planofstudys/getplanofstudyandstudents"));
} }
[HttpPost] [HttpPost]
public void ReportPlanOfStudyAndStudents(string type) public void ReportPlanOfStudyAndStudents(string type)
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
Redirect("~/Home/Enter"); Redirect("~/Home/Enter");
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
} }
if (type == "pdf") if (type == "pdf")
{ {
APIClient.PostRequest("api/planofstudys/createreporttopdffile", new ReportBindingModel APIClient.PostRequest("api/planofstudys/createreporttopdffile", new ReportBindingModel
{ {
FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\Ñâåäåíèÿ ïî ïëàíàì îáó÷åíèÿ.pdf" FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\Ñâåäåíèÿ ïî ïëàíàì îáó÷åíèÿ.pdf"
}); });
APIClient.PostRequest("api/planofstudys/sendpdftomail", new MailSendInfoBindingModel APIClient.PostRequest("api/planofstudys/sendpdftomail", new MailSendInfoBindingModel
{ {
MailAddress = APIClient.User.Email, MailAddress = APIClient.User.Email,
Subject = "Îò÷åò", Subject = "Îò÷åò",
Text = "Ñâåäåíèÿ ïî ïëàíàì îáó÷åíèÿ" Text = "Ñâåäåíèÿ ïî ïëàíàì îáó÷åíèÿ"
}); });
} }
Response.Redirect("Index"); Response.Redirect("Index");
return; return;
} }
} }
} }

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=DESKTOP-N8BRIPR\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);
} }