fix
This commit is contained in:
parent
13c761e9ba
commit
c2143fc676
@ -3,6 +3,7 @@ using FluentNHibernate;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using System.Diagnostics;
|
||||
using TravelCompanyBusinessLogic.BusinessLogic.TouristLogics;
|
||||
using TravelCompanyBusinessLogic.BusinessLogics;
|
||||
using TravelCompanyClientApp.Models;
|
||||
using TravelCompanyContracts.BindingModels;
|
||||
@ -27,20 +28,20 @@ namespace TravelCompanyClientApp.Controllers
|
||||
private readonly ITravelLogic _travellogic;
|
||||
private readonly IReportLogic _reportlogic;
|
||||
private readonly IOperatorLogic _operatorlogic;
|
||||
private readonly ITourLogic _tourLogic;
|
||||
private readonly IGuideLogic _guidelogic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger,ITouristLogic logic, ITravelLogic travelLogic,IReportLogic reportLogic
|
||||
,IOperatorLogic operatorLogic)
|
||||
,IOperatorLogic operatorLogic, ITourLogic tourLogic, IGuideLogic guideLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_travellogic = travelLogic;
|
||||
_reportlogic = reportLogic;
|
||||
_operatorlogic = operatorLogic;
|
||||
|
||||
if (_operatorlogic.ReadList(null).Count == 0)
|
||||
{
|
||||
|
||||
}
|
||||
_tourLogic = tourLogic;
|
||||
_guidelogic = guideLogic;
|
||||
LoadFromJson();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -221,82 +222,41 @@ namespace TravelCompanyClientApp.Controllers
|
||||
public List<GuideBindingModel> LoadGuidesFromJson(string jsonFilePath)
|
||||
{
|
||||
string jsonData = System.IO.File.ReadAllText(jsonFilePath);
|
||||
var jsonObject = JsonConvert.DeserializeObject<Dictionary<string, List<ServiceBindingModel>>>(jsonData);
|
||||
var guides = jsonObject["service"];
|
||||
var jsonObject = JsonConvert.DeserializeObject<Dictionary<string, List<GuideBindingModel>>>(jsonData);
|
||||
var guides = jsonObject["guide"];
|
||||
return guides;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
if (_juristLogic.ReadList(null) != null)
|
||||
{
|
||||
string jsonFilePath = "automatic.json";
|
||||
List<JuristBindingModel> jurists = LoadJuristsFromJson(jsonFilePath);
|
||||
List<ServiceBindingModel> services = LoadServicesFromJson(jsonFilePath);
|
||||
|
||||
foreach (var jurist in jurists)
|
||||
{
|
||||
_juristLogic.Create(jurist);
|
||||
}
|
||||
|
||||
foreach (var service in services)
|
||||
{
|
||||
_serviceLogic.Create(service);
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(_meetingLogic.ReadList(new MeetingSearchModel { ClientId = APIClient.Client.Id }));
|
||||
}
|
||||
|
||||
public List<JuristBindingModel> LoadJuristsFromJson(string jsonFilePath)
|
||||
public List<OperatorBindingModel> LoadOperatorsFromJson(string jsonFilePath)
|
||||
{
|
||||
string jsonData = System.IO.File.ReadAllText(jsonFilePath);
|
||||
var jsonObject = JsonConvert.DeserializeObject<Dictionary<string, List<JuristBindingModel>>>(jsonData);
|
||||
var jurists = jsonObject["jurist"];
|
||||
return jurists;
|
||||
var jsonObject = JsonConvert.DeserializeObject<Dictionary<string, List<OperatorBindingModel>>>(jsonData);
|
||||
var operators = jsonObject["operator"];
|
||||
return operators;
|
||||
}
|
||||
|
||||
public List<ServiceBindingModel> LoadServicesFromJson(string jsonFilePath)
|
||||
public void LoadFromJson()
|
||||
{
|
||||
string jsonData = System.IO.File.ReadAllText(jsonFilePath);
|
||||
var jsonObject = JsonConvert.DeserializeObject<Dictionary<string, List<ServiceBindingModel>>>(jsonData);
|
||||
var services = jsonObject["service"];
|
||||
return services;
|
||||
}
|
||||
|
||||
/* [HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
if (_operatorlogic.ReadList(null).Count==0)
|
||||
{
|
||||
if (_juristLogic.ReadList(null) != null)
|
||||
string jsonFilePath = "automatic.json";
|
||||
List<TourBindingModel> tours = LoadToursFromJson(jsonFilePath);
|
||||
List<GuideBindingModel> guides = LoadGuidesFromJson(jsonFilePath);
|
||||
List<OperatorBindingModel> operators = LoadOperatorsFromJson(jsonFilePath);
|
||||
foreach (var o in operators)
|
||||
{
|
||||
string jsonFilePath = "automatic.json";
|
||||
List<JuristBindingModel> jurists = LoadJuristsFromJson(jsonFilePath);
|
||||
List<ServiceBindingModel> services = LoadServicesFromJson(jsonFilePath);
|
||||
|
||||
foreach (var jurist in jurists)
|
||||
{
|
||||
_juristLogic.Create(jurist);
|
||||
}
|
||||
|
||||
foreach (var service in services)
|
||||
{
|
||||
_serviceLogic.Create(service);
|
||||
}
|
||||
_operatorlogic.Create(o);
|
||||
}
|
||||
foreach (var t in tours)
|
||||
{
|
||||
_tourLogic.Create(t);
|
||||
}
|
||||
|
||||
return Redirect("~/Home/Enter");
|
||||
foreach (var g in guides)
|
||||
{
|
||||
_guidelogic.Create(g);
|
||||
}
|
||||
}
|
||||
return View(_meetingLogic.ReadList(new MeetingSearchModel { ClientId = APIClient.Client.Id }));
|
||||
}
|
||||
2.txt
|
||||
2 кб*/
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user