сайт заработал

This commit is contained in:
Milana Ievlewa 2024-05-07 16:12:08 +03:00
parent e98411296f
commit 0246fa80c3
52 changed files with 2085 additions and 190 deletions

View File

@ -6,4 +6,13 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DataModels\DataModels.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,95 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StoragesContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class CommentLogic : ICommentLogic
{
private readonly ICommentStorage _projectStorage;
public CommentLogic(ICommentStorage projectStorage)
{
_projectStorage = projectStorage;
}
public List<CommentViewModel>? ReadList(CommentSearchModel? model)
{
var list = model == null ? _projectStorage.GetFullList() : _projectStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public CommentViewModel? ReadElement(CommentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _projectStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(CommentBindingModel model)
{
CheckModel(model);
if (_projectStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(CommentBindingModel model)
{
CheckModel(model);
if (_projectStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(CommentBindingModel model)
{
CheckModel(model, false);
if (_projectStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(CommentBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.TEXT))
{
throw new ArgumentNullException("Нет текста комментария", nameof(model.TEXT));
}
var element = _projectStorage.GetElement(new CommentSearchModel
{
TEXT = model.TEXT
});
if (element != null && element.Id != model.Id && element.PerformerId == model.PerformerId && element.TaskId == model.TaskId)
{
throw new InvalidOperationException("Такой комментарий уже существует");
}
}
}
}

View File

@ -0,0 +1,98 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StoragesContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class PerformerLogic : IPerformerLogic
{
private readonly IPerformerStorage _performerStorage;
public PerformerLogic(IPerformerStorage performerStorage)
{
_performerStorage = performerStorage;
}
public List<PerformerViewModel>? ReadList(PerformerSearchModel? model)
{
var list = model == null ? _performerStorage.GetFullList() : _performerStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public PerformerViewModel? ReadElement(PerformerSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _performerStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(PerformerBindingModel model)
{
CheckModel(model);
if (_performerStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(PerformerBindingModel model)
{
CheckModel(model);
if (_performerStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(PerformerBindingModel model)
{
CheckModel(model, false);
if (_performerStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(PerformerBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.NAME_PF))
{
throw new ArgumentNullException("Отсутствует имя",
nameof(model.NAME_PF));
}
if (string.IsNullOrEmpty(model.login))
{
throw new ArgumentNullException("Отсутствует логин",
nameof(model.login));
}
if (string.IsNullOrEmpty(model.password))
{
throw new ArgumentNullException("Отсутствует пароль",
nameof(model.password));
}
}
}
}

View File

@ -0,0 +1,96 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StoragesContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class ProjectLogic : IProjectLogic
{
private readonly IProjectStorage _projectStorage;
public ProjectLogic(IProjectStorage projectStorage)
{
_projectStorage = projectStorage;
}
public List<ProjectViewModel>? ReadList(ProjectSearchModel? model)
{
var list = model == null ? _projectStorage.GetFullList() : _projectStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public ProjectViewModel? ReadElement(ProjectSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _projectStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(ProjectBindingModel model)
{
CheckModel(model);
if (_projectStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(ProjectBindingModel model)
{
CheckModel(model);
if (_projectStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(ProjectBindingModel model)
{
CheckModel(model, false);
if (_projectStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(ProjectBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.NAME_PJ))
{
throw new ArgumentNullException("Нет названия",
nameof(model.NAME_PJ));
}
var element = _projectStorage.GetElement(new ProjectSearchModel
{
NAME_PJ = model.NAME_PJ
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Проект с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,96 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StoragesContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class TagGroupLogic : ITagGroupLogic
{
private readonly ITagGroupStorage _projectStorage;
public TagGroupLogic(ITagGroupStorage projectStorage)
{
_projectStorage = projectStorage;
}
public List<TagGroupViewModel>? ReadList(TagGroupSearchModel? model)
{
var list = model == null ? _projectStorage.GetFullList() : _projectStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public TagGroupViewModel? ReadElement(TagGroupSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _projectStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(TagGroupBindingModel model)
{
CheckModel(model);
if (_projectStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(TagGroupBindingModel model)
{
CheckModel(model);
if (_projectStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(TagGroupBindingModel model)
{
CheckModel(model, false);
if (_projectStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(TagGroupBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.NAME_TG))
{
throw new ArgumentNullException("Нет названия",
nameof(model.NAME_TG));
}
var element = _projectStorage.GetElement(new TagGroupSearchModel
{
NAME_TG = model.NAME_TG
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("такой тег уже есть");
}
}
}
}

View File

@ -0,0 +1,96 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StoragesContracts;
using Contracts.ViewModels;
using DataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class TaskLogic : ITaskLogic
{
private readonly ITaskStorage _taskStorage;
public TaskLogic(ITaskStorage taskStorage)
{
_taskStorage = taskStorage;
}
public bool CreateTask(TaskBindingModel model)
{
CheckModel(model);
if (model.Status != MyTaskStatus.Неизвестен)
{
return false;
}
model.Status = MyTaskStatus.Новый;
if (_taskStorage.Insert(model) == null)
{
return false;
}
return true;
}
public List<TaskViewModel>? ReadList(TaskSearchModel? model)
{
var list = _taskStorage.GetFullList();
if (list == null)
{
return null;
}
return list;
}
public bool TakeTaskInWork(TaskBindingModel model)
{
return ChangeStatus(model, MyTaskStatus.Выполняется);
}
public bool FinishTask(TaskBindingModel model)
{
return ChangeStatus(model, MyTaskStatus.Готово);
}
private void CheckModel(TaskBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
}
private bool ChangeStatus(TaskBindingModel model, MyTaskStatus newStatus)
{
CheckModel(model, false);
var task = _taskStorage.GetElement(new TaskSearchModel { Id = model.Id });
if (task == null)
{
return false;
}
if (task.Status + 1 != newStatus)
{
return false;
}
model.Status = newStatus;
if (model.Status != MyTaskStatus.Готово && task.DEADLINE > DateTime.Now)
{
model.Status += 1;
}
if (_taskStorage.Update(model) == null)
{
return false;
}
return true;
}
}
}

View File

@ -0,0 +1,96 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StoragesContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class TeamLogic : ITeamLogic
{
private readonly ITeamStorage _projectStorage;
public TeamLogic(ITeamStorage projectStorage)
{
_projectStorage = projectStorage;
}
public List<TeamViewModel>? ReadList(TeamSearchModel? model)
{
var list = model == null ? _projectStorage.GetFullList() : _projectStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public TeamViewModel? ReadElement(TeamSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _projectStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(TeamBindingModel model)
{
CheckModel(model);
if (_projectStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(TeamBindingModel model)
{
CheckModel(model);
if (_projectStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(TeamBindingModel model)
{
CheckModel(model, false);
if (_projectStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(TeamBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.NAME_TM))
{
throw new ArgumentNullException("Нет названия",
nameof(model.NAME_TM));
}
var element = _projectStorage.GetElement(new TeamSearchModel
{
TeamName = model.NAME_TM
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("команда с таким названием уже есть");
}
}
}
}

View File

@ -1,7 +0,0 @@
namespace BusinessLogic
{
public class Class1
{
}
}

View File

@ -0,0 +1,46 @@
using Contracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace ClientApp
{
public static class APIClient
{
private static readonly HttpClient _client = new();
public static PerformerViewModel? Client { get; set; } = null;
public static void Connect(IConfiguration configuration)
{
_client.BaseAddress = new Uri(configuration["IPAddress"]);
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new
MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)
{
var response = _client.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<T>(result);
}
else
{
throw new Exception(result);
}
}
public static void PostRequest<T>(string requestUrl, T model)
{
var json = JsonConvert.SerializeObject(model);
var data = new StringContent(json, Encoding.UTF8,
"application/json");
var response = _client.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(result);
}
}
}
}

View File

@ -6,4 +6,15 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BusinessLogic\BusinessLogic.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\DataModels\DataModels.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -1,6 +1,10 @@
using ClientApp.Models; using ClientApp.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Diagnostics; using System.Diagnostics;
using Contracts.BindingModels;
using Contracts.ViewModels;
using DataModels;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace ClientApp.Controllers namespace ClientApp.Controllers
{ {
@ -13,20 +17,226 @@ namespace ClientApp.Controllers
_logger = logger; _logger = logger;
} }
public IActionResult Index() public IActionResult Index()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
// Передача имени пользователя в представление
ViewData["UserName"] = APIClient.Client.NAME_PF;
return View();
}
[HttpGet]
public IActionResult Privacy()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.Client);
}
[HttpPost]
public void Privacy(string login, string password, string fio)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/client/updatedata", new PerformerBindingModel
{
Id = APIClient.Client.Id,
NAME_PF = fio,
login = login,
password = password
});
APIClient.Client.NAME_PF = fio;
APIClient.Client.login = login;
APIClient.Client.password = password;
Response.Redirect("Index");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[HttpGet]
public IActionResult Enter()
{
return View();
}
[HttpPost]
public void Enter(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIClient.Client = APIClient.GetRequest<PerformerViewModel>($"api/client/login?login={login}&password={password}");
if (APIClient.Client == null)
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
}
[HttpGet]
public IActionResult Register()
{
return View();
}
[HttpPost]
public void Register(string login, string password, string fio, string specialty)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(specialty))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/client/register", new PerformerBindingModel
{
NAME_PF = fio,
login = login,
password = password,
SPECIALTY = specialty
});
Response.Redirect("Enter");
return;
}
[HttpGet]
public IActionResult CreateProject()
{
ViewBag.Teams =
APIClient.GetRequest<List<TeamViewModel>>("api/main/getteamlist");
return View();
}
[HttpPost]
public void CreateProject(int Team, string name, string description)
{ {
return View(); if (APIClient.Client == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/main/createproject", new ProjectBindingModel
{
TeamId = Team,
NAME_PJ = name,
DESCRIPTION_PJ = description
});
Response.Redirect("Index");
} }
public IActionResult Privacy() [HttpGet]
public IActionResult CreateTask()
{
ViewBag.Projects =
APIClient.GetRequest<List<ProjectViewModel>>("api/main/getprojectlist");
ViewBag.TagGroups =
APIClient.GetRequest<List<TagGroupViewModel>>("api/main/gettagslist");
return View();
}
[HttpPost]
public void CreateTask(string shortDesc, string description, DateTime deadline, int Project, int Tag)
{ {
return View(); if (APIClient.Client == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/main/createtask", new TaskBindingModel
{
SHORT_DESC = shortDesc,
DESCRIPTION = description,
DEADLINE = deadline,
ProjectId = Project,
TagGroupId = Tag,
Status = MyTaskStatus.Неизвестен
});
Response.Redirect("Index");
} }
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [HttpGet]
public IActionResult Error() public IActionResult CreateComment()
{
ViewBag.Tasks =
APIClient.GetRequest<List<TaskViewModel>>("api/main/gettasklist");
return View();
}
[HttpPost]
public void CreateComment(int Task, string Text)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest("api/main/createcomment", new CommentBindingModel
{
PerformerId = APIClient.Client.Id,
TaskId = Task,
TEXT = Text
});
Response.Redirect("Index");
}
public IActionResult ViewComments()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<CommentViewModel>>($"api/main/getcomments?PerformerId={APIClient.Client.Id}"));
}
[HttpGet]
public IActionResult ViewTasks()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
var tasks = APIClient.GetRequest<List<TaskViewModel>>($"api/main/gettasklist");
var tasksForPerformer = tasks.Where(task => task.TaskPerformers.Any(tp => tp.Key == APIClient.Client.Id)).ToList();
return View(tasksForPerformer);
}
[HttpGet]
public IActionResult ViewProjects()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<ProjectViewModel>>("api/main/getprojectlist"));
}
[HttpPost]
public void AssignPerformerToTask(int taskId, int performerId)
{ {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); if (APIClient.Client == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/main/assigntaskperformer", new TaskPerformerBindingModel
{
TaskId = taskId,
PerformerId = performerId
});
Response.Redirect("Index");
} }
} }
} }

View File

@ -1,3 +1,5 @@
using ClientApp;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
@ -5,12 +7,14 @@ builder.Services.AddControllersWithViews();
var app = builder.Build(); var app = builder.Build();
APIClient.Connect(builder.Configuration);
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
@ -21,7 +25,7 @@ app.UseRouting();
app.UseAuthorization(); app.UseAuthorization();
app.MapControllerRoute( app.MapControllerRoute(
name: "default", name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"); pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run(); app.Run();

View File

@ -0,0 +1,30 @@
@using Contracts.ViewModels
@model CommentViewModel
@{
ViewData["Title"] = "Create";
}
<div class="text-center">
<h2 class="display-4">Комментарий</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Задача:</div>
<div class="col-8">
<select id="Task" name="Task" class="form-control" asp-items="@(new SelectList(@ViewBag.Tasks,"Id", "SHORT_DESC"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Текст комментария:</div>
<div class="col-8">
<input type="text" name="Text" id="Text" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,35 @@
@using Contracts.ViewModels
@model ProjectViewModel
@{
ViewData["Title"] = "Create Project";
}
<div class="text-center">
<h2 class="display-4">Проект</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Команда:</div>
<div class="col-8">
<select id="Team" name="Team" class="form-control" asp-items="@(new SelectList(@ViewBag.Teams,"Id", "NAME_TM"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8">
<input type="text" name="name" id="name" />
</div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8">
<input type="text" name="description" id="description" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,50 @@
@using Contracts.ViewModels
@model TaskViewModel
@{
ViewData["Title"] = "Create";
}
<div class="text-center">
<h2 class="display-4">Создание задачи</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Проект:</div>
<div class="col-8">
<select id="Project" name="Project" class="form-control" asp-items="@(new SelectList(@ViewBag.Projects,"Id", "NAME_PJ"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Тег:</div>
<div class="col-8">
<select id="Tag" name="Tag" class="form-control" asp-items="@(new SelectList(@ViewBag.TagGroups,"Id", "NAME_TG"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Краткое описание:</div>
<div class="col-8">
<input type="text" name="shortDesc" id="shortDesc" />
</div>
</div>
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8">
<input type="text" name="description" id="description" />
</div>
</div>
<div class="row">
<div class="col-4">Дедлайн:</div>
<div class="col-8">
<input type="datetime-local" name="deadline" id="deadline" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,20 @@
@{
ViewData["Title"] = "Enter";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -1,8 +1,17 @@
@{ @using ClientApp.Models
@{
ViewData["Title"] = "Home Page"; ViewData["Title"] = "Home Page";
} }
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Welcome</h1> <h1 class="display-4">Добро пожаловать, @ViewData["UserName"]!</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p> </div>
<div class="text-center">
<p>
<a asp-action="ViewProjects">Все проекты</a> |
<a asp-action="ViewTasks">Все задачи</a> |
<a asp-action="ViewComments">Все комментарии</a>
</p>
</div> </div>

View File

@ -1,6 +1,46 @@
@{ @using Contracts.ViewModels
@model PerformerViewModel
@{
ViewData["Title"] = "Privacy Policy"; ViewData["Title"] = "Privacy Policy";
} }
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p> <div class="text-center">
<h2 class="display-4">Личные данные</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8">
<input type="text" name="login"
value="@Model.login" />
</div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8">
<input type="password" name="password"
value="@Model.password" />
</div>
</div>
<div class="row">
<div class="col-4">ФИО:</div>
<div class="col-8">
<input type="text" name="fio"
value="@Model.NAME_PF" />
</div>
</div>
<div class="row">
<div class="col-4">Специальность:</div>
<div class="col-8">
<input type="text" name="specialty"
value="@Model.SPECIALTY" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Сохранить" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,31 @@
@{
ViewData["Title"] = "Register";
}
<div class="text-center">
<h2 class="display-4">Регистрация</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-4">ФИО:</div>
<div class="col-8"><input type="text" name="fio" /></div>
</div>
<div class="row">
<div class="col-4">Специальность:</div>
<div class="col-8"><input type="text" name="specialty" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Регистрация"
class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,63 @@
@using Contracts.ViewModels
@model List<CommentViewModel>
@{
ViewData["Title"] = "View Comments";
}
<div class="text-center">
<h1 class="display-4">Комментарии</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
}
<p>
<a asp-controller="Home" asp-action="CreateComment">Создать комментарий</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Задача
</th>
<th>
Автор
</th>
<th>
Текст
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.TaskName)
</td>
<td>
@Html.DisplayFor(modelItem => item.PerformerName)
</td>
<td>
@Html.DisplayFor(modelItem => item.TEXT)
</td>
</tr>
}
</tbody>
</table>
</div>

View File

@ -0,0 +1,61 @@
@using Contracts.ViewModels
@model List<ProjectViewModel>
@{
ViewData["Title"] = "View Projects";
}
<div class="text-center">
<h1 class="display-4">Проекты</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateProject">Создать проект</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название
</th>
<th>
Описание
</th>
<th>
Команда
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.NAME_PJ)
</td>
<td>
@Html.DisplayFor(modelItem => item.DESCRIPTION_PJ)
</td>
<td>
@Html.DisplayFor(modelItem => item.TeamId)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,79 @@
@using Contracts.ViewModels
@model List<TaskViewModel>
@{
ViewData["Title"] = "View Tasks";
}
<div class="text-center">
<h1 class="display-4">Задачи</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateTask">Создать задачу</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Задача
</th>
<th>
Описание
</th>
<th>
Статус
</th>
<th>
Дедлайн
</th>
<th>
Проект
</th>
<th>
Тег
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.SHORT_DESC)
</td>
<td>
@Html.DisplayFor(modelItem => item.DESCRIPTION)
</td>
<td>
@Html.DisplayFor(modelItem => item.Status)
</td>
<td>
@Html.DisplayFor(modelItem => item.DEADLINE)
</td>
<td>
@Html.DisplayFor(modelItem => item.ProjectId)
</td>
<td>
@Html.DisplayFor(modelItem => item.TagGroupId)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -3,27 +3,39 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - ClientApp</title> <title>@ViewData["Title"] - TaskTrackerClientApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /> <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/ClientApp.styles.css" asp-append-version="true" /> <link rel="stylesheet" href="~/TaskTrackerClientApp.styles.css" asp-append-version="true" />
</head> </head>
<body> <body>
<header> <header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
<div class="container-fluid"> <div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">ClientApp</a> <a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">TaskTracker</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" <button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation"> aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between"> <div class="navbar-collapse collapse d-sm-inline-flex flex-smrow-reverse">
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a> <a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> <a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ViewTasks">Задачи</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ViewProjects">Проекты</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ViewComments">Комментарии</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -38,7 +50,7 @@
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted">
<div class="container"> <div class="container">
&copy; 2024 - ClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> &copy; 2024 - TaskTracker - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div> </div>
</footer> </footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>

View File

@ -5,5 +5,6 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*",
"IPAddress": "http://localhost:5229"
} }

View File

@ -11,6 +11,10 @@ namespace Contracts.BindingModels
{ {
public int Id{ get; set; } public int Id{ get; set; }
public string NAME_PF { get; set; } = string.Empty; public string NAME_PF { get; set; } = string.Empty;
public string login { get; set; } = string.Empty;
public string password { get; set; } = string.Empty;
public string SPECIALTY { get; set; } = string.Empty; public string SPECIALTY { get; set; } = string.Empty;
public int TeamId { get; set; } public int TeamId { get; set; }
} }

View File

@ -17,7 +17,7 @@ namespace Contracts.BindingModels
public int ProjectId { get; set; } public int ProjectId { get; set; }
public int TagGroupId { get; set; } public int TagGroupId { get; set; }
public MyTaskStatus Status { get; set; } = MyTaskStatus.Неизвестен; public MyTaskStatus Status { get; set; } = MyTaskStatus.Неизвестен;
public Dictionary<int, IPerformerModel> TaskPerformers public Dictionary<int, string> TaskPerformers
{ {
get; get;
set; set;

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModels
{
public class TaskPerformerBindingModel
{
public int TaskId { get; set; }
public int PerformerId { get; set; }
}
}

View File

@ -15,6 +15,5 @@ namespace Contracts.BusinessLogicContracts
bool CreateTask(TaskBindingModel model); bool CreateTask(TaskBindingModel model);
bool TakeTaskInWork(TaskBindingModel model); bool TakeTaskInWork(TaskBindingModel model);
bool FinishTask(TaskBindingModel model); bool FinishTask(TaskBindingModel model);
bool DeliveryTask(TaskBindingModel model);
} }
} }

View File

@ -9,6 +9,7 @@ namespace Contracts.SearchModels
public class CommentSearchModel public class CommentSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string? TEXT { get; set; }
public int? TaskId { get; set; } public int? TaskId { get; set; }
public int? PerformerId { get; set; } public int? PerformerId { get; set; }
} }

View File

@ -10,6 +10,8 @@ namespace Contracts.SearchModels
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string? NAME_PF { get; set; } public string? NAME_PF { get; set; }
public string? login { get; set; }
public string? password { get; set; }
public int? TeamId { get; set; } public int? TeamId { get; set; }
} }
} }

View File

@ -12,5 +12,6 @@ namespace Contracts.SearchModels
public string? SHORT_DESC { get; set; } public string? SHORT_DESC { get; set; }
public int? ProjectId { get; set; } public int? ProjectId { get; set; }
public int? TagGroupId { get; set; } public int? TagGroupId { get; set; }
public List<int>? PerformerIds { get; set; }
} }
} }

View File

@ -12,7 +12,6 @@ namespace Contracts.StoragesContracts
public interface ITaskStorage public interface ITaskStorage
{ {
List<TaskViewModel> GetFullList(); List<TaskViewModel> GetFullList();
List<TaskViewModel> GetFilteredList(TaskSearchModel model);
TaskViewModel? GetElement(TaskSearchModel model); TaskViewModel? GetElement(TaskSearchModel model);
TaskViewModel? Insert(TaskBindingModel model); TaskViewModel? Insert(TaskBindingModel model);
TaskViewModel? Update(TaskBindingModel model); TaskViewModel? Update(TaskBindingModel model);

View File

@ -16,6 +16,12 @@ namespace Contracts.ViewModels
[DisplayName("Имя")] [DisplayName("Имя")]
public string NAME_PF { get; set; } = string.Empty; public string NAME_PF { get; set; } = string.Empty;
[DisplayName("Логин")]
public string login { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string password { get; set; } = string.Empty;
[DisplayName("Специальность")] [DisplayName("Специальность")]
public string SPECIALTY { get; set; } = string.Empty; public string SPECIALTY { get; set; } = string.Empty;

View File

@ -34,7 +34,7 @@ namespace Contracts.ViewModels
[DisplayName("Тег")] [DisplayName("Тег")]
public string TagName { get; set; } = string.Empty; public string TagName { get; set; } = string.Empty;
public Dictionary<int, IPerformerModel> TaskPerformers public Dictionary<int, string> TaskPerformers
{ {
get; get;
set; set;

View File

@ -9,6 +9,8 @@ namespace DataModels.Models
public interface IPerformerModel : IId public interface IPerformerModel : IId
{ {
string NAME_PF { get; } string NAME_PF { get; }
string login { get; }
string password { get; }
string SPECIALTY { get; } string SPECIALTY { get; }
int TeamId { get; } int TeamId { get; }
} }

View File

@ -14,6 +14,6 @@ namespace DataModels.Models
int ProjectId { get; } int ProjectId { get; }
int TagGroupId { get; } int TagGroupId { get; }
MyTaskStatus Status { get; } MyTaskStatus Status { get; }
Dictionary<int, IPerformerModel> TaskPerformers { get; } //комментарии к задаче Dictionary<int, string> TaskPerformers { get; } //комментарии к задаче
} }
} }

View File

@ -16,6 +16,7 @@ namespace DataModels
Готово = 2, Готово = 2,
Проверено = 3 Просрочено = 3
} }
} }

View File

@ -17,11 +17,11 @@ namespace DatabaseImplement.Implements
public List<PerformerViewModel> GetFullList() public List<PerformerViewModel> GetFullList()
{ {
using var context = new TaskTrackerDatabase(); using var context = new TaskTrackerDatabase();
return context.Performers return context.Performers
.Include(x => x.Team) .Include(x => x.Team)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
public List<PerformerViewModel> GetFilteredList(PerformerSearchModel model) public List<PerformerViewModel> GetFilteredList(PerformerSearchModel model)
{ {
@ -45,20 +45,21 @@ namespace DatabaseImplement.Implements
return new(); return new();
} }
public PerformerViewModel? GetElement(PerformerSearchModel model) public PerformerViewModel? GetElement(PerformerSearchModel model)
{ {
if (!model.Id.HasValue) if (string.IsNullOrEmpty(model.login) && string.IsNullOrEmpty(model.password) && !model.Id.HasValue)
{ {
return null; return null;
} }
using var context = new TaskTrackerDatabase(); using var context = new TaskTrackerDatabase();
return context.Performers return context.Performers
.Include(x => x.Team) .Include (x => x.Team)
.FirstOrDefault(x => x.Id == model.Id) .FirstOrDefault(x =>
?.GetViewModel; (!string.IsNullOrEmpty(model.login) && x.login == model.login && !string.IsNullOrEmpty(model.password) && x.password == model.password)
} || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public PerformerViewModel? Insert(PerformerBindingModel model) public PerformerViewModel? Insert(PerformerBindingModel model)
{ {
var newPerformer = Performer.Create(model); var newPerformer = Performer.Create(model);
if (newPerformer == null) if (newPerformer == null)

View File

@ -26,23 +26,6 @@ namespace DatabaseImplement.Implements
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
public List<TaskViewModel> GetFilteredList(TaskSearchModel model)
{
if (string.IsNullOrEmpty(model.SHORT_DESC))
{
return new();
}
using var context = new TaskTrackerDatabase();
return context.Tasks
.Include(x => x.Project)
.Include(x => x.TagGroup)
.Include(x => x.Performers)
.ThenInclude(x => x.Performer)
.Where(x => x.SHORT_DESC.Contains(model.SHORT_DESC))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public TaskViewModel? GetElement(TaskSearchModel model) public TaskViewModel? GetElement(TaskSearchModel model)
{ {
if (string.IsNullOrEmpty(model.SHORT_DESC) && !model.Id.HasValue) if (string.IsNullOrEmpty(model.SHORT_DESC) && !model.Id.HasValue)
@ -55,22 +38,26 @@ namespace DatabaseImplement.Implements
.Include(x => x.TagGroup) .Include(x => x.TagGroup)
.Include(x => x.Performers) .Include(x => x.Performers)
.ThenInclude(x => x.Performer) .ThenInclude(x => x.Performer)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SHORT_DESC) && x.SHORT_DESC == model.SHORT_DESC) || .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
} }
public TaskViewModel? Insert(TaskBindingModel model) public TaskViewModel? Insert(TaskBindingModel model)
{ {
using var context = new TaskTrackerDatabase(); var newTask = Task.Create(model);
var newReinforced = Task.Create(context, model); if (newTask == null)
if (newReinforced == null) {
{ return null;
return null; }
} using var context = new TaskTrackerDatabase();
context.Tasks.Add(newReinforced); context.Tasks.Add(newTask);
context.SaveChanges(); context.SaveChanges();
return newReinforced.GetViewModel; return context.Tasks
} .Include(x => x.Project)
.Include(x => x.TagGroup)
.Include(x => x.Performers)
.ThenInclude(x => x.Performer)
.FirstOrDefault(x => x.Id == newTask.Id)
?.GetViewModel;
}
public TaskViewModel? Update(TaskBindingModel model) public TaskViewModel? Update(TaskBindingModel model)
{ {
using var context = new TaskTrackerDatabase(); using var context = new TaskTrackerDatabase();
@ -93,20 +80,27 @@ namespace DatabaseImplement.Implements
transaction.Rollback(); transaction.Rollback();
throw; throw;
} }
} }
public TaskViewModel? Delete(TaskBindingModel model) public TaskViewModel? Delete(TaskBindingModel model)
{ {
using var context = new TaskTrackerDatabase(); using var context = new TaskTrackerDatabase();
var element = context.Tasks var element = context.Tasks
.Include(x => x.Performers) .Include(x => x.Performers)
.FirstOrDefault(rec => rec.Id == model.Id); .FirstOrDefault(rec => rec.Id == model.Id);
if (element != null) if (element != null)
{ {
context.Tasks.Remove(element); var deletedElement = context.Tasks
context.SaveChanges(); .Include(x => x.Project)
return element.GetViewModel; .Include(x => x.TagGroup)
} .Include(x => x.Performers)
.ThenInclude(x => x.Performer)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Tasks.Remove(element);
context.SaveChanges();
return deletedElement;
}
return null; return null;
} }
} }
} }

View File

@ -0,0 +1,302 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(TaskTrackerDatabase))]
[Migration("20240504174026_addSomePerformerStuff")]
partial class addSomePerformerStuff
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Comment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("PerformerId")
.HasColumnType("integer");
b.Property<string>("TEXT")
.IsRequired()
.HasColumnType("text");
b.Property<int>("TaskId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PerformerId");
b.HasIndex("TaskId");
b.ToTable("Comments");
});
modelBuilder.Entity("DatabaseImplement.Models.Performer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("NAME_PF")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SPECIALTY")
.IsRequired()
.HasColumnType("text");
b.Property<int>("TeamId")
.HasColumnType("integer");
b.Property<string>("login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Performers");
});
modelBuilder.Entity("DatabaseImplement.Models.Project", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DESCRIPTION_PJ")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NAME_PJ")
.IsRequired()
.HasColumnType("text");
b.Property<int>("TeamId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Projects");
});
modelBuilder.Entity("DatabaseImplement.Models.TagGroup", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("COLOR")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NAME_TG")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("TagGroups");
});
modelBuilder.Entity("DatabaseImplement.Models.Task", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("DEADLINE")
.HasColumnType("timestamp without time zone");
b.Property<string>("DESCRIPTION")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ProjectId")
.HasColumnType("integer");
b.Property<string>("SHORT_DESC")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<int>("TagGroupId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ProjectId");
b.HasIndex("TagGroupId");
b.ToTable("Tasks");
});
modelBuilder.Entity("DatabaseImplement.Models.TaskPerformers", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("PerformerId")
.HasColumnType("integer");
b.Property<int>("TaskId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PerformerId");
b.HasIndex("TaskId");
b.ToTable("TaskPerformers");
});
modelBuilder.Entity("DatabaseImplement.Models.Team", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("NAME_TM")
.IsRequired()
.HasColumnType("text");
b.Property<double>("RATING")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Teams");
});
modelBuilder.Entity("DatabaseImplement.Models.Comment", b =>
{
b.HasOne("DatabaseImplement.Models.Performer", "Performer")
.WithMany()
.HasForeignKey("PerformerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Task", "Task")
.WithMany()
.HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Performer");
b.Navigation("Task");
});
modelBuilder.Entity("DatabaseImplement.Models.Performer", b =>
{
b.HasOne("DatabaseImplement.Models.Team", "Team")
.WithMany()
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("DatabaseImplement.Models.Project", b =>
{
b.HasOne("DatabaseImplement.Models.Team", "Team")
.WithMany()
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("DatabaseImplement.Models.Task", b =>
{
b.HasOne("DatabaseImplement.Models.Project", "Project")
.WithMany()
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.TagGroup", "TagGroup")
.WithMany()
.HasForeignKey("TagGroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Project");
b.Navigation("TagGroup");
});
modelBuilder.Entity("DatabaseImplement.Models.TaskPerformers", b =>
{
b.HasOne("DatabaseImplement.Models.Performer", "Performer")
.WithMany()
.HasForeignKey("PerformerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Task", "Task")
.WithMany("Performers")
.HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Performer");
b.Navigation("Task");
});
modelBuilder.Entity("DatabaseImplement.Models.Task", b =>
{
b.Navigation("Performers");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class addSomePerformerStuff : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "login",
table: "Performers",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "password",
table: "Performers",
type: "text",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "login",
table: "Performers");
migrationBuilder.DropColumn(
name: "password",
table: "Performers");
}
}
}

View File

@ -68,6 +68,14 @@ namespace DatabaseImplement.Migrations
b.Property<int>("TeamId") b.Property<int>("TeamId")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("TeamId"); b.HasIndex("TeamId");

View File

@ -48,8 +48,6 @@ namespace DatabaseImplement.Models
return; return;
} }
TEXT = model.TEXT; TEXT = model.TEXT;
PerformerId = model.PerformerId;
TaskId = model.TaskId;
} }
public CommentViewModel GetViewModel => new() public CommentViewModel GetViewModel => new()

View File

@ -17,6 +17,12 @@ namespace DatabaseImplement.Models
[Required] [Required]
public string NAME_PF { get; private set; } = string.Empty; public string NAME_PF { get; private set; } = string.Empty;
[Required]
public string login { get; private set; } = string.Empty;
[Required]
public string password { get; private set; } = string.Empty;
[Required] [Required]
public string SPECIALTY { get; private set; } = string.Empty; public string SPECIALTY { get; private set; } = string.Empty;
@ -36,6 +42,8 @@ namespace DatabaseImplement.Models
NAME_PF = model.NAME_PF, NAME_PF = model.NAME_PF,
SPECIALTY = model.SPECIALTY, SPECIALTY = model.SPECIALTY,
TeamId = model.TeamId, TeamId = model.TeamId,
login = model.login,
password = model.password
}; };
} }
@ -47,16 +55,19 @@ namespace DatabaseImplement.Models
} }
NAME_PF = model.NAME_PF; NAME_PF = model.NAME_PF;
SPECIALTY = model.SPECIALTY; SPECIALTY = model.SPECIALTY;
TeamId = model.TeamId; login = model.login;
password = model.password;
} }
public PerformerViewModel GetViewModel => new() public PerformerViewModel GetViewModel => new()
{ {
Id = Id, Id = Id,
NAME_PF = NAME_PF, NAME_PF = NAME_PF,
SPECIALTY = SPECIALTY, SPECIALTY = SPECIALTY,
TeamId = TeamId, TeamId = TeamId,
TeamName = Team.NAME_TM TeamName = Team.NAME_TM,
}; login = login,
} password = password
};
}
} }

View File

@ -47,7 +47,6 @@ namespace DatabaseImplement.Models
} }
NAME_PJ = model.NAME_PJ; NAME_PJ = model.NAME_PJ;
DESCRIPTION_PJ = model.DESCRIPTION_PJ; DESCRIPTION_PJ = model.DESCRIPTION_PJ;
TeamId = model.TeamId;
} }
public ProjectViewModel GetViewModel => new() public ProjectViewModel GetViewModel => new()

View File

@ -21,8 +21,6 @@ namespace DatabaseImplement.Models
[Required] [Required]
public string DESCRIPTION { get; set;} = string.Empty; public string DESCRIPTION { get; set;} = string.Empty;
[Required]
public MyTaskStatus Status { get; set; } public MyTaskStatus Status { get; set; }
[Required] [Required]
@ -37,16 +35,16 @@ namespace DatabaseImplement.Models
public virtual TagGroup TagGroup { get; set; } public virtual TagGroup TagGroup { get; set; }
private Dictionary<int, IPerformerModel>? _taskPerformers = null; private Dictionary<int, string>? _taskPerformers = null;
[NotMapped] [NotMapped]
public Dictionary<int, IPerformerModel> TaskPerformers public Dictionary<int, string> TaskPerformers
{ {
get get
{ {
if (_taskPerformers == null) if (_taskPerformers == null)
{ {
_taskPerformers = Performers _taskPerformers = Performers
.ToDictionary(recPC => recPC.PerformerId, recPC => recPC.Performer as IPerformerModel); .ToDictionary(recPC => recPC.PerformerId, recPC => recPC.Performer.NAME_PF);
} }
return _taskPerformers; return _taskPerformers;
} }
@ -55,35 +53,39 @@ namespace DatabaseImplement.Models
public virtual List<TaskPerformers> Performers { get; set; } = new(); public virtual List<TaskPerformers> Performers { get; set; } = new();
public static Task? Create(TaskTrackerDatabase context, TaskBindingModel? model) public static Task? Create(TaskBindingModel? model)
{ {
if (model == null) if (model == null)
{ {
return null; return null;
} }
return new Task() using var context = new TaskTrackerDatabase();
{ var task = new Task()
Id = model.Id, {
SHORT_DESC = model.SHORT_DESC, Id = model.Id,
DESCRIPTION = model.DESCRIPTION, SHORT_DESC = model.SHORT_DESC,
Status = model.Status, DESCRIPTION = model.DESCRIPTION,
DEADLINE = model.DEADLINE, DEADLINE = model.DEADLINE,
ProjectId = model.ProjectId, ProjectId = model.ProjectId,
TagGroupId = model.TagGroupId, TagGroupId = model.TagGroupId,
Performers = model.TaskPerformers.Select(x => new TaskPerformers Performers = model.TaskPerformers.Select(x => new TaskPerformers
{ {
Performer = context.Performers.First(y => y.Id == x.Key) Performer = context.Performers.First(y => y.Id == x.Key)
}).ToList() }).ToList()
}; };
}
public void Update(TaskBindingModel? model) return task;
}
public void Update(TaskBindingModel? model)
{ {
if (model == null) if (model == null)
{ {
return; return;
} }
Status = model.Status; SHORT_DESC = model.SHORT_DESC;
DESCRIPTION = model.DESCRIPTION;
DEADLINE = model.DEADLINE;
} }
public TaskViewModel GetViewModel => new() public TaskViewModel GetViewModel => new()
@ -91,7 +93,6 @@ namespace DatabaseImplement.Models
Id = Id, Id = Id,
SHORT_DESC = SHORT_DESC, SHORT_DESC = SHORT_DESC,
DESCRIPTION = DESCRIPTION, DESCRIPTION = DESCRIPTION,
Status = Status,
DEADLINE = DEADLINE, DEADLINE = DEADLINE,
ProjectId = ProjectId, ProjectId = ProjectId,
ProjectName = Project.NAME_PJ, ProjectName = Project.NAME_PJ,

View File

@ -0,0 +1,64 @@
using Microsoft.AspNetCore.Mvc;
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.ViewModels;
namespace TaskTrackerRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ClientController : Controller
{
private readonly IPerformerLogic _logic;
public ClientController(IPerformerLogic logic)
{
_logic = logic;
}
[HttpGet]
public PerformerViewModel? Login(string login, string password)
{
try
{
return _logic.ReadElement(new PerformerSearchModel
{
login = login,
password = password
});
}
catch
{
throw;
}
}
[HttpPost]
public void Register(PerformerBindingModel model)
{
try
{
_logic.Create(model);
}
catch
{
throw;
}
}
[HttpPost]
public void UpdateData(PerformerBindingModel model)
{
try
{
_logic.Update(model);
}
catch
{
throw;
}
}
}
}

View File

@ -0,0 +1,176 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
using DatabaseImplement.Models;
using DatabaseImplement;
namespace TaskTrackerRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class MainController : Controller
{
private readonly ITaskLogic _task;
private readonly IProjectLogic _project;
private readonly ICommentLogic _comment;
private readonly ITeamLogic _team;
private readonly ITagGroupLogic _tagGroup;
public MainController(ITaskLogic task, IProjectLogic project, ICommentLogic comment, ITeamLogic team, ITagGroupLogic tagGroupLogic)
{
_task = task;
_project = project;
_comment = comment;
_team = team;
_tagGroup = tagGroupLogic;
}
[HttpGet]
public List<TagGroupViewModel>? GetTagsList()
{
try
{
return _tagGroup.ReadList(null);
}
catch
{
throw;
}
}
[HttpGet]
public List<ProjectViewModel>? GetProjectList()
{
try
{
return _project.ReadList(null);
}
catch
{
throw;
}
}
[HttpPost]
public void CreateProject(ProjectBindingModel model)
{
try
{
_project.Create(model);
}
catch
{
throw;
}
}
[HttpGet]
public List<CommentViewModel>? GetCommentsList()
{
try
{
return _comment.ReadList(null);
}
catch
{
throw;
}
}
[HttpGet]
public List<CommentViewModel>? GetComments(int PerformerId)
{
try
{
return _comment.ReadList(new CommentSearchModel { PerformerId = PerformerId });
}
catch
{
throw;
}
}
[HttpPost]
public void CreateComment(CommentBindingModel model)
{
try
{
_comment.Create(model);
}
catch
{
throw;
}
}
[HttpGet]
public List<TeamViewModel>? GetTeamList()
{
try
{
return _team.ReadList(null);
}
catch
{
throw;
}
}
[HttpGet]
public List<TeamViewModel>? GetTeams(int teamId)
{
try
{
return _team.ReadList(new TeamSearchModel { Id = teamId });
}
catch
{
throw;
}
}
[HttpPost]
public void CreateTeam(TeamBindingModel model)
{
try
{
_team.Create(model);
}
catch
{
throw;
}
}
[HttpGet]
public List<TaskViewModel>? GetTaskList()
{
try
{
return _task.ReadList(null);
}
catch
{
throw;
}
}
[HttpPost]
public void CreateTask(TaskBindingModel model)
{
try
{
_task.CreateTask(model);
}
catch
{
throw;
}
}
}
}

View File

@ -1,33 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace RestApi.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

View File

@ -1,11 +1,40 @@
using BusinessLogic.BusinessLogic;
using Contracts.BusinessLogicContracts;
using Contracts.StoragesContracts;
using DatabaseImplement.Implements;
using Microsoft.AspNetCore.Identity;
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
builder.Services.AddTransient<ICommentStorage, CommentStorage>();
builder.Services.AddTransient<IPerformerStorage, PerformerStorage>();
builder.Services.AddTransient<IProjectStorage, ProjectStorage>();
builder.Services.AddTransient<ITagGroupStorage, TagGroupStorage>();
builder.Services.AddTransient<ITaskStorage, TaskStorage>();
builder.Services.AddTransient<ITeamStorage, TeamStorage>();
builder.Services.AddTransient<ICommentLogic, CommentLogic>();
builder.Services.AddTransient<IPerformerLogic, PerformerLogic>();
builder.Services.AddTransient<IProjectLogic, ProjectLogic>();
builder.Services.AddTransient<ITagGroupLogic, TagGroupLogic>();
builder.Services.AddTransient<ITaskLogic, TaskLogic>();
builder.Services.AddTransient<ITeamLogic, TeamLogic>();
builder.Services.AddControllers(); builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Title = "TaskTrackerRestApi",
Version
= "v1"
});
});
var app = builder.Build(); var app = builder.Build();
@ -13,7 +42,8 @@ var app = builder.Build();
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
"TaskTrackerRestApi v1"));
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -10,4 +10,11 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BusinessLogic\BusinessLogic.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\DataModels\DataModels.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -1,13 +0,0 @@
namespace RestApi
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}