89 lines
1.9 KiB
C#
89 lines
1.9 KiB
C#
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using System.Diagnostics;
|
|||
|
using TaskTrackerContracts.BindingModels;
|
|||
|
using TaskTrackerContracts.SearchModels;
|
|||
|
using TaskTrackerContracts.ViewModels;
|
|||
|
|
|||
|
namespace TaskTrackerClientApp.Controllers
|
|||
|
{
|
|||
|
public class ProjectController : Controller
|
|||
|
{
|
|||
|
private readonly ILogger<ProjectController> _logger;
|
|||
|
public ProjectController(ILogger<ProjectController> logger)
|
|||
|
{
|
|||
|
_logger = logger;
|
|||
|
}
|
|||
|
|
|||
|
[HttpGet]
|
|||
|
public IActionResult CreateProject()
|
|||
|
{
|
|||
|
return View();
|
|||
|
}
|
|||
|
[HttpPost]
|
|||
|
public void CreateProject(string name, string state)
|
|||
|
{
|
|||
|
|
|||
|
if (APIClient.Company == null)
|
|||
|
{
|
|||
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
|||
|
}
|
|||
|
|
|||
|
APIClient.PostRequest("api/project/createproject", new
|
|||
|
ProjectBindingModel
|
|||
|
{
|
|||
|
CompanyId = APIClient.Company.Id,
|
|||
|
Name = name,
|
|||
|
State = state,
|
|||
|
|
|||
|
});
|
|||
|
Response.Redirect("/Home/Index");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
[HttpPost]
|
|||
|
public void DeleteProject(int id)
|
|||
|
{
|
|||
|
if (APIClient.Company == null)
|
|||
|
{
|
|||
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
|||
|
}
|
|||
|
|
|||
|
APIClient.PostRequest("api/project/deleteproject", new
|
|||
|
ProjectSearchModel
|
|||
|
{
|
|||
|
Id = id,
|
|||
|
CompanyId = APIClient.Company.Id,
|
|||
|
Name = "fgdf"
|
|||
|
|
|||
|
|
|||
|
}) ;
|
|||
|
Response.Redirect("/Home/Index");
|
|||
|
}
|
|||
|
[HttpGet]
|
|||
|
public IActionResult UpdateProject()
|
|||
|
{
|
|||
|
return View();
|
|||
|
}
|
|||
|
[HttpPost]
|
|||
|
public void UpdateProject(int id, string name, string state)
|
|||
|
{
|
|||
|
if (APIClient.Company == null)
|
|||
|
{
|
|||
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
|||
|
}
|
|||
|
|
|||
|
APIClient.PostRequest("api/project/updateproject", new
|
|||
|
ProjectBindingModel
|
|||
|
{
|
|||
|
CompanyId = APIClient.Company.Id,
|
|||
|
Name = name,
|
|||
|
State = state,
|
|||
|
Id = id
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
Response.Redirect("/Home/Index");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|