view пока только project и home
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SoftwareContracts.BindingModels;
|
||||
using SoftwareContracts.ViewModels;
|
||||
using SoftwareRestApi.Controllers;
|
||||
|
||||
namespace SoftwareApplication.Controllers
|
||||
{
|
||||
public class IssueController : Controller
|
||||
{
|
||||
private readonly ILogger<IssueController> _logger;
|
||||
|
||||
public IssueController(ILogger<IssueController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet("/issue")]
|
||||
public IActionResult Issues()
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(ApiClient.GetRequest<List<IssueViewModel>>($"api/issue/getissuelist"));
|
||||
}
|
||||
|
||||
[HttpGet("/issue/save/{id?}")]
|
||||
public IActionResult Create(int? id)
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
if (!id.HasValue)
|
||||
{
|
||||
return View(new IssueViewModel());
|
||||
|
||||
}
|
||||
ViewBag.Projects = ApiClient.GetRequest<List<ProjectViewModel>>($"api/project/getprojectlist");
|
||||
var model = ApiClient.GetRequest<IssueViewModel?>($"api/issue/getissue?id={id}");
|
||||
return View(model);
|
||||
|
||||
}
|
||||
|
||||
[HttpPost("/issue/save/{id?}")]
|
||||
public void Create(IssueBindingModel model)
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
throw new Exception("Доступно только авторизованным пользователям");
|
||||
}
|
||||
if (model.Id != 0)
|
||||
{
|
||||
ApiClient.PostRequest("api/issue/update", model);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApiClient.PostRequest("api/issue/create", model);
|
||||
}
|
||||
|
||||
Response.Redirect("/issue");
|
||||
}
|
||||
|
||||
[HttpPost("/issue/delete")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
throw new Exception("Доступно только авторизованным пользователям");
|
||||
}
|
||||
|
||||
ApiClient.PostRequest($"api/issue/delete", new IssueBindingModel { Id = id });
|
||||
Response.Redirect("/issue");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace SoftwareApplication.Controllers
|
||||
{
|
||||
|
||||
public class LogsController : Controller
|
||||
{
|
||||
private readonly ILogger<LogsController> _logger;
|
||||
|
||||
public LogsController(ILogger<LogsController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
[HttpGet("/logs")]
|
||||
public IActionResult DownloadLog()
|
||||
{
|
||||
try
|
||||
{
|
||||
var file = ApiClient.GetFile("api/logs/download");
|
||||
|
||||
return File(file.Bytes, file.ContentType, file.FileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while downloading log file");
|
||||
TempData["Error"] = "Не удалось скачать лог-файл.";
|
||||
return RedirectToAction("Management");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SoftwareContracts.BindingModels;
|
||||
using SoftwareContracts.ViewModels;
|
||||
|
||||
namespace SoftwareApplication.Controllers
|
||||
{
|
||||
public class ProjectController : Controller
|
||||
{
|
||||
private readonly ILogger<ProjectController> _logger;
|
||||
|
||||
public ProjectController(ILogger<ProjectController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet("/project")]
|
||||
public IActionResult Projects()
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(ApiClient.GetRequest<List<ProjectViewModel>>($"api/project/getprojectlist"));
|
||||
}
|
||||
|
||||
[HttpGet("/project/save/{id?}")]
|
||||
public IActionResult Create(int? id)
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
if (!id.HasValue)
|
||||
{
|
||||
return View(new ProjectViewModel());
|
||||
|
||||
}
|
||||
var model = ApiClient.GetRequest<ProjectViewModel?>($"api/project/getproject?id={id}");
|
||||
return View(model);
|
||||
|
||||
}
|
||||
|
||||
[HttpPost("/project/save/{id?}")]
|
||||
public void Create(ProjectBindingModel model)
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
throw new Exception("Доступно только авторизованным пользователям");
|
||||
}
|
||||
if (model.Id != 0)
|
||||
{
|
||||
ApiClient.PostRequest("api/project/update", model);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApiClient.PostRequest("api/project/create", model);
|
||||
}
|
||||
|
||||
Response.Redirect("/project");
|
||||
}
|
||||
|
||||
[HttpPost("/project/delete")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
throw new Exception("Доступно только авторизованным пользователям");
|
||||
}
|
||||
|
||||
ApiClient.PostRequest($"api/project/delete", new ProjectBindingModel { Id = id });
|
||||
Response.Redirect("/project");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SoftwareContracts.BindingModels;
|
||||
using SoftwareContracts.ViewModels;
|
||||
using SoftwareRestApi.Controllers;
|
||||
|
||||
namespace SoftwareApplication.Controllers
|
||||
{
|
||||
public class TestController : Controller
|
||||
{
|
||||
private readonly ILogger<TestController> _logger;
|
||||
|
||||
public TestController(ILogger<TestController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet("/test")]
|
||||
public IActionResult Tests()
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(ApiClient.GetRequest<List<TestViewModel>>($"api/test/gettestlist"));
|
||||
}
|
||||
|
||||
[HttpGet("/test/save/{id?}")]
|
||||
public IActionResult Create(int? id)
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
if (!id.HasValue)
|
||||
{
|
||||
return View(new TestViewModel());
|
||||
}
|
||||
ViewBag.Projects = ApiClient.GetRequest<List<ProjectViewModel>>($"api/project/getprojectlist");
|
||||
var model = ApiClient.GetRequest<TestViewModel?>($"api/test/gettest?id={id}");
|
||||
return View(model);
|
||||
|
||||
}
|
||||
|
||||
[HttpPost("/test/save/{id?}")]
|
||||
public void Create(TestBindingModel model)
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
throw new Exception("Доступно только авторизованным пользователям");
|
||||
}
|
||||
if (model.Id != 0)
|
||||
{
|
||||
ApiClient.PostRequest("api/test/update", model);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApiClient.PostRequest("api/test/create", model);
|
||||
}
|
||||
|
||||
Response.Redirect("/recipe");
|
||||
}
|
||||
|
||||
[HttpPost("/test/delete")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (ApiClient.User == null)
|
||||
{
|
||||
throw new Exception("Доступно только авторизованным пользователям");
|
||||
}
|
||||
|
||||
ApiClient.PostRequest($"api/test/delete", new TestBindingModel { Id = id });
|
||||
Response.Redirect("/test");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user