фигня
This commit is contained in:
parent
a230039ed0
commit
cdc415a487
@ -2,7 +2,9 @@
|
||||
using System.Diagnostics;
|
||||
using ZooClientApp.Models;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.SearchModels;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDataModels.Models;
|
||||
|
||||
namespace ZooClientApp.Controllers
|
||||
{
|
||||
@ -144,6 +146,47 @@ namespace ZooClientApp.Controllers
|
||||
);
|
||||
return count * (prod?.PreservePrice ?? 1);
|
||||
}
|
||||
//Маршруты
|
||||
public IActionResult IndexRoute()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
var helpme = APIClient.GetRequest<List<RouteViewModel>>($"api/route/getroutes?clientid={APIClient.Client.Id}");
|
||||
return View(helpme);
|
||||
}
|
||||
public IActionResult CreateRoute()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Preserves = APIClient.GetRequest<List<PreserveViewModel>>($"api/preserve/getpreserves?clientid={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateRoute(string name, List<int> preserves, DateTime dateTime)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
Dictionary<int, IPreserveModel> a = new Dictionary<int, IPreserveModel>();
|
||||
foreach (int pet in preserves)
|
||||
{
|
||||
a.Add(pet, new PreserveSearchModel { Id = pet } as IPreserveModel);
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/route/createroute", new RouteBindingModel
|
||||
{
|
||||
ClientId = APIClient.Client.Id,
|
||||
RoutePreserves = a,
|
||||
DateStart = dateTime,
|
||||
RouteName = name
|
||||
});
|
||||
Response.Redirect("IndexRoute");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Mails()
|
||||
|
@ -24,7 +24,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-4">Дата начала:</div>
|
||||
<div class="col-8">
|
||||
<input type="datetime-local" id="datetime" name="datetime" />
|
||||
</div>
|
||||
@ -36,14 +36,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
$('#drug').on('change', function () {
|
||||
check();
|
||||
});
|
||||
$('#count').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -30,6 +30,9 @@
|
||||
<th>
|
||||
Маршрут
|
||||
</th>
|
||||
<th>
|
||||
Статус
|
||||
</th>
|
||||
<th>
|
||||
Дата начала
|
||||
</th>
|
||||
@ -45,6 +48,9 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.RoutePrice)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateStart)
|
||||
</td>
|
||||
|
@ -12,7 +12,7 @@ namespace ZooRestApi.Controllers
|
||||
private readonly IReportEmployeeLogic _report;
|
||||
public ReportControllerEmployee(ILogger<ReportControllerEmployee> logger, IReportEmployeeLogic report)
|
||||
{
|
||||
logger = logger;
|
||||
_logger = logger;
|
||||
_report = report;
|
||||
}
|
||||
[Microsoft.AspNetCore.Mvc.HttpGet]
|
||||
|
109
git/JurasicZoo/ZooRestApi/Controllers/RouteController.cs
Normal file
109
git/JurasicZoo/ZooRestApi/Controllers/RouteController.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZooContracts.BindingModels;
|
||||
using ZooContracts.BusinessLogicsContracts;
|
||||
using ZooContracts.SearchModels;
|
||||
using ZooContracts.ViewModels;
|
||||
using ZooDataBaseImplement.Models;
|
||||
|
||||
namespace ZooRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class RouteController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRouteLogic _route;
|
||||
public RouteController(ILogger<RouteController> logger, IRouteLogic route)
|
||||
{
|
||||
_logger = logger;
|
||||
_route = route;
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<RouteViewModel, List<string>>? GetRoutes(int visitId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _route.ReadElement(new RouteSearchModel { Id = visitId });
|
||||
if (elem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var res = Tuple.Create(elem, elem.RoutePreserves.Select(x => x.Value.PreserveName).ToList());
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения визита по id={Id}", visitId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<RouteViewModel>? GetRoutes(int? clientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _route.ReadList(new RouteSearchModel { ClientId = clientId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка маршрутов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<RouteViewModel> GetAllVisits()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _route.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка маршрутов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool CreateVisit(RouteBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _route.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось создать маршрут");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateVisit(RouteBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _route.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить маршрута");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool DeleteVisit(RouteBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _route.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления маршрутп");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user