delete WeatherForecast
This commit is contained in:
parent
78c625122d
commit
e4a611748c
@ -11,38 +11,38 @@ namespace AutoWorkshopClientApp
|
||||
|
||||
public static ClientViewModel? Client { get; set; } = null;
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
public static void Connect(IConfiguration Configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_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)
|
||||
public static T? GetRequest<T>(string RequestUrl)
|
||||
{
|
||||
var response = _client.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
var Response = _client.GetAsync(RequestUrl);
|
||||
var Result = Response.Result.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
if (Response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
return JsonConvert.DeserializeObject<T>(Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
throw new Exception(Result);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
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;
|
||||
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)
|
||||
if (!Response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
throw new Exception(Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ namespace AutoWorkshopClientApp.Controllers
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
public HomeController(ILogger<HomeController> Logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_logger = Logger;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -21,6 +21,7 @@ namespace AutoWorkshopClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(ApiClient.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={ApiClient.Client.Id}"));
|
||||
}
|
||||
|
||||
@ -31,6 +32,7 @@ namespace AutoWorkshopClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(ApiClient.Client);
|
||||
}
|
||||
|
||||
@ -41,22 +43,24 @@ namespace AutoWorkshopClientApp.Controllers
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
ApiClient.PostRequest("api/client/updatedata", new
|
||||
ClientBindingModel
|
||||
|
||||
ApiClient.PostRequest("api/client/updatedata", new ClientBindingModel
|
||||
{
|
||||
Id = ApiClient.Client.Id,
|
||||
ClientFIO = fio,
|
||||
Email = login,
|
||||
Password = password
|
||||
});
|
||||
|
||||
ApiClient.Client.ClientFIO = fio;
|
||||
ApiClient.Client.Email = login;
|
||||
ApiClient.Client.Password = password;
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
@ -78,16 +82,18 @@ namespace AutoWorkshopClientApp.Controllers
|
||||
[HttpPost]
|
||||
public void Enter(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password))
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите логин и пароль");
|
||||
}
|
||||
|
||||
ApiClient.Client = ApiClient.GetRequest<ClientViewModel>($"api/client/login?login={login}&password={password}");
|
||||
|
||||
if (ApiClient.Client == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
@ -104,6 +110,7 @@ namespace AutoWorkshopClientApp.Controllers
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
|
||||
ApiClient.PostRequest("api/client/register", new ClientBindingModel
|
||||
{
|
||||
ClientFIO = fio,
|
||||
@ -123,30 +130,31 @@ namespace AutoWorkshopClientApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(int Repair, int Count)
|
||||
public void Create(int repair, int count)
|
||||
{
|
||||
if (ApiClient.Client == null)
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
|
||||
if (Count <= 0)
|
||||
if (count <= 0)
|
||||
throw new Exception("Количество и сумма должны быть больше 0");
|
||||
|
||||
|
||||
ApiClient.PostRequest("api/main/createorder", new OrderBindingModel
|
||||
{
|
||||
ClientId = ApiClient.Client.Id,
|
||||
RepairId = Repair,
|
||||
Count = Count,
|
||||
Sum = Calc(Count, Repair)
|
||||
RepairId = repair,
|
||||
Count = count,
|
||||
Sum = Calc(count, repair)
|
||||
});
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public double Calc(int count, int repair)
|
||||
{
|
||||
var rep = ApiClient.GetRequest<RepairViewModel>($"api/main/getrepair?repairId={repair}");
|
||||
return count * (rep?.Price ?? 1);
|
||||
RepairViewModel? Repair = ApiClient.GetRequest<RepairViewModel>($"api/main/getrepair?repairId={repair}");
|
||||
return count * (Repair?.Price ?? 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,7 @@
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn
|
||||
btn-primary" />
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -10,66 +10,60 @@
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="Create">Создать заказ</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<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.RepairName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.DateCreate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Count)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Status)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
<a asp-action="Create">Создать заказ</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<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.RepairName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => Item.DateCreate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => Item.Count)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => Item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => Item.Status)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -4,27 +4,31 @@
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
<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.Email"/></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.ClientFIO"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn
|
||||
btn-primary" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="login" value="@Model.Email"/>
|
||||
</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.ClientFIO"/>
|
||||
</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>
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - RepairShopClientApp</title>
|
||||
<title>@ViewData["Title"] - AutoWorkshopClientApp</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" />
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
@ -11,23 +11,23 @@ namespace AutoWorkshopRestApi.Controllers
|
||||
public class ClientController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientLogic _logic;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
|
||||
public ClientController(IClientLogic logic, ILogger<ClientController> logger)
|
||||
public ClientController(IClientLogic ClientLogic, ILogger<ClientController> Logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_logger = Logger;
|
||||
_clientLogic = ClientLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ClientViewModel? Login(string login, string password)
|
||||
public ClientViewModel? Login(string Login, string Password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ClientSearchModel
|
||||
return _clientLogic.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Email = login,
|
||||
Password = password
|
||||
Email = Login,
|
||||
Password = Password
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -38,11 +38,11 @@ namespace AutoWorkshopRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Register(ClientBindingModel model)
|
||||
public void Register(ClientBindingModel Model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
_clientLogic.Create(Model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -52,11 +52,11 @@ namespace AutoWorkshopRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateData(ClientBindingModel model)
|
||||
public void UpdateData(ClientBindingModel Model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
_clientLogic.Update(Model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -36,45 +36,45 @@ namespace AutoWorkshopRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public RepairViewModel? GetRepair(int repairId)
|
||||
public RepairViewModel? GetRepair(int RepairId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _repair.ReadElement(new RepairSearchModel
|
||||
{
|
||||
Id = repairId
|
||||
Id = RepairId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения продукта по id={Id}", repairId);
|
||||
_logger.LogError(ex, "Ошибка получения продукта по id={Id}", RepairId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<OrderViewModel>? GetOrders(int clientId)
|
||||
public List<OrderViewModel>? GetOrders(int ClientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _order.ReadList(new OrderSearchModel
|
||||
{
|
||||
ClientId = clientId
|
||||
ClientId = ClientId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов клиента id ={ Id} ", clientId);
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов клиента id ={ Id} ", ClientId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateOrder(OrderBindingModel model)
|
||||
public void CreateOrder(OrderBindingModel Model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_order.CreateOrder(model);
|
||||
_order.CreateOrder(Model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,33 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace AutoWorkshopRestApi.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();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,20 +4,21 @@ using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopDatabaseImplement.Implements;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
builder.Logging.AddLog4Net("log4net.config");
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IRepairStorage, RepairStorage>();
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<IRepairLogic, RepairLogic>();
|
||||
builder.Services.AddControllers();
|
||||
var Builder = WebApplication.CreateBuilder(args);
|
||||
Builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
Builder.Logging.AddLog4Net("log4net.config");
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
// Add services to the container.
|
||||
Builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
Builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
Builder.Services.AddTransient<IRepairStorage, RepairStorage>();
|
||||
Builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
Builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
Builder.Services.AddTransient<IRepairLogic, RepairLogic>();
|
||||
Builder.Services.AddControllers();
|
||||
|
||||
Builder.Services.AddEndpointsApiExplorer();
|
||||
Builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
@ -25,15 +26,18 @@ builder.Services.AddSwaggerGen(c =>
|
||||
Version = "v1"
|
||||
});
|
||||
});
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
var App = Builder.Build();
|
||||
|
||||
if (App.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
|
||||
App.UseSwagger();
|
||||
App.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
|
||||
"AutoWorkshopRestApi v1"));
|
||||
}
|
||||
app.UseHttpsRedirection();
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
app.Run();
|
||||
|
||||
App.UseHttpsRedirection();
|
||||
App.UseAuthorization();
|
||||
App.MapControllers();
|
||||
|
||||
App.Run();
|
||||
|
@ -1,13 +0,0 @@
|
||||
namespace AutoWorkshopRestApi
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<log4net>
|
||||
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
||||
<file value="c:/temp/CarRepairShopRestApi.log" />
|
||||
<file value="c:/temp/AutoWorkshopRestApi.log" />
|
||||
<appendToFile value="true" />
|
||||
<maximumFileSize value="100KB" />
|
||||
<maxSizeRollBackups value="2" />
|
||||
|
@ -7,34 +7,37 @@ namespace AutoWorkshopView.Forms
|
||||
public partial class FormClients : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientLogic _logic;
|
||||
public FormClients(ILogger<FormClients> logger, IClientLogic logic)
|
||||
private readonly IClientLogic _clientLogic;
|
||||
|
||||
public FormClients(ILogger<FormClients> Logger, IClientLogic ClientLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
|
||||
_logger = Logger;
|
||||
_clientLogic = ClientLogic;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
var List = _clientLogic.ReadList(null);
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.DataSource = List;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["Email"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки клиентов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,25 +52,25 @@ namespace AutoWorkshopView.Forms
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
int Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление клиента");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ClientBindingModel
|
||||
if (!_clientLogic.Delete(new ClientBindingModel
|
||||
{
|
||||
Id = id
|
||||
Id = Id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user