cruds ready. DAITE TRI
This commit is contained in:
parent
24578ea1ee
commit
f461b880dd
@ -72,7 +72,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
}
|
||||
public List<CarViewModel>? ReadList(CarSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. CarName:{CarName}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var list = model == null ? _CarStorage.GetFullList() : _CarStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -72,7 +72,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
}
|
||||
public List<EquipmentViewModel>? ReadList(EquipmentSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Equipment:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var list = model == null ? _EquipmentStorage.GetFullList() : _EquipmentStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -76,7 +76,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
|
||||
public List<PresellingWorkViewModel>? ReadList(PresellingWorkSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. PresellingWork:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var list = model == null ? _PresellingWorkStorage.GetFullList() : _PresellingWorkStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -72,7 +72,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
}
|
||||
public List<PurchaseViewModel>? ReadList(PurchaseSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Purchase: Id:{Id}", model.Id);
|
||||
|
||||
var list = model == null ? _PurchaseStorage.GetFullList() : _PurchaseStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -76,7 +76,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
|
||||
public List<UserViewModel>? ReadList(UserSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. UserEmail:{UserFIO}.Id:{Id}", model.Email, model.Id);
|
||||
|
||||
var list = model == null ? _UserStorage.GetFullList() : _UserStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -76,7 +76,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
|
||||
public List<WishViewModel>? ReadList(WishSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Wish:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var list = model == null ? _WishStorage.GetFullList() : _WishStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace AutoCenterContracts.BindingModels
|
||||
public class CarBindingModel : ICarModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public Dictionary<int, IEquipmentModel> CarEquipments { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ namespace AutoCenterContracts.BindingModels
|
||||
public class EquipmentBindingModel : IEquipmentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
}
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ namespace AutoCenterContracts.BindingModels
|
||||
public class PresellingWorkBindingModel : IPresellingWorkModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ namespace AutoCenterContracts.BindingModels
|
||||
public class WishBindingModel : IWishModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int PresellingWorkId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public int PresellingWorkId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -40,21 +40,21 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Cars.Include(x => x.Purchases).Include(x => x.Equipments).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Cars.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public List<CarViewModel> GetFilteredList(CarSearchModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Cars.Include(x => x.Purchases).Include(x => x.Equipments).Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
return context.Cars.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<CarViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Cars.Include(x => x.Purchases).Include(x => x.Equipments).Select(x => x.GetViewModel).ToList();
|
||||
return context.Cars.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public CarViewModel? Insert(CarBindingModel model)
|
||||
{
|
||||
|
@ -48,8 +48,8 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Equipments.Include(x => x.Cars)
|
||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) && (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name) &&
|
||||
(!string.IsNullOrEmpty(model.Description) || x.Description == model.Description)))
|
||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Name) || x.Name == model.Name) &&
|
||||
(string.IsNullOrEmpty(model.Description) || x.Description == model.Description)))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
|
||||
return context.PresellingWorks.Include(x => x.Wishes)
|
||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
&& (!string.IsNullOrEmpty(model.Description) || x.Description == model.Description)
|
||||
&& (string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
&& (string.IsNullOrEmpty(model.Description) || x.Description == model.Description)
|
||||
&& (!model.UserId.HasValue || x.UserId == model.UserId)
|
||||
))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
|
@ -39,13 +39,13 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Purchases.Include(x => x.PresellingWorks).Include(x => x.Cars).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Purchases.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Purchases.Include(x => x.PresellingWorks).Include(x => x.Cars).Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
return context.Purchases.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!model.IsCashPaid.HasValue || x.IsCashPaid == model.IsCashPaid)
|
||||
&& (!model.UserId.HasValue || x.UserId == model.UserId)
|
||||
&& (!model.Date.HasValue || x.Date == model.Date)))
|
||||
@ -55,7 +55,7 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Purchases.Include(x => x.PresellingWorks).Include(x => x.Cars).Select(x => x.GetViewModel).ToList();
|
||||
return context.Purchases.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public PurchaseViewModel? Insert(PurchaseBindingModel model)
|
||||
{
|
||||
|
@ -51,10 +51,10 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Users.Include(x => x.Purchases).Include(x => x.PresellingWorks).Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Username) || x.Username == model.Username)
|
||||
&& (!string.IsNullOrEmpty(model.Password) || x.Password == model.Password)
|
||||
&& (!string.IsNullOrEmpty(model.PhoneNumber) || x.PhoneNumber == model.PhoneNumber)
|
||||
&& (!string.IsNullOrEmpty(model.Email) || x.Email == model.Email)
|
||||
&& (string.IsNullOrEmpty(model.Username) || x.Username == model.Username)
|
||||
&& (string.IsNullOrEmpty(model.Password) || x.Password == model.Password)
|
||||
&& (string.IsNullOrEmpty(model.PhoneNumber) || x.PhoneNumber == model.PhoneNumber)
|
||||
&& (string.IsNullOrEmpty(model.Email) || x.Email == model.Email)
|
||||
))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Wishes.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
&& (!string.IsNullOrEmpty(model.Description) || x.Description == model.Description)
|
||||
&& (string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
&& (string.IsNullOrEmpty(model.Description) || x.Description == model.Description)
|
||||
&& (!model.PresellingWorkId.HasValue || x.PresellingWorkId == model.PresellingWorkId)
|
||||
))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
|
@ -117,7 +117,7 @@ namespace AutoCenterDatabaseImplement.Migrations
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
onDelete: ReferentialAction.NoAction);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -186,7 +186,7 @@ namespace AutoCenterDatabaseImplement.Migrations
|
||||
column: x => x.PurchasesId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.NoAction);
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
|
@ -45,9 +45,7 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Equipments = model.CarEquipments.Select(x => new Equipment {
|
||||
Id = context.Equipments.First(y => y.Id == x.Key).Id
|
||||
}).ToList(),
|
||||
Equipments = model.CarEquipments.Select(x => context.Equipments.First(y => y.Id == x.Key)).ToList(),
|
||||
};
|
||||
}
|
||||
public void Update(CarBindingModel? model)
|
||||
|
@ -21,7 +21,6 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public int UserId { get;private set; }
|
||||
public virtual User User { get; set; } = new();
|
||||
|
||||
public List<Wish> Wishes { get; set; } = new();
|
||||
|
||||
@ -38,7 +37,8 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Description = model.Description
|
||||
Description = model.Description,
|
||||
UserId = model.UserId
|
||||
};
|
||||
}
|
||||
|
||||
@ -52,13 +52,15 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
Id = model.Id;
|
||||
Name = model.Name;
|
||||
Description = model.Description;
|
||||
|
||||
}
|
||||
|
||||
public PresellingWorkViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Description = Description,
|
||||
Name = Name
|
||||
Name = Name,
|
||||
UserId = UserId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -63,14 +63,8 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
IsCashPaid = model.IsCashPaid,
|
||||
UserId = model.UserId,
|
||||
Date = model.Date,
|
||||
Cars = model.PurchaseCars.Select(x => new Car
|
||||
{
|
||||
Id = context.Cars.First(y => y.Id == x.Key).Id
|
||||
}).ToList(),
|
||||
PresellingWorks = model.PurchasePresellingWorks.Select(x => new PresellingWork
|
||||
{
|
||||
Id = context.Equipments.First(y => y.Id == x.Key).Id
|
||||
}).ToList()
|
||||
Cars = model.PurchaseCars.Select(x => context.Cars.First(y => y.Id == x.Key)).ToList(),
|
||||
PresellingWorks = model.PurchasePresellingWorks.Select(x => context.PresellingWorks.First(y => y.Id == x.Key)).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
public string Description { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int PresellingWorkId { get; set; }
|
||||
public virtual PresellingWork PresellingWork { get; set; } = new();
|
||||
|
||||
public static Wish? Create(WishBindingModel model)
|
||||
{
|
||||
@ -52,6 +51,7 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
public WishViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Description = Description,
|
||||
PresellingWorkId = PresellingWorkId
|
||||
};
|
||||
|
@ -118,7 +118,7 @@ namespace AutoCenterUserApp.Controllers
|
||||
}
|
||||
|
||||
ViewBag.Cars = APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist");
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<CarViewModel>>($"api/presellignwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<CarViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ namespace AutoCenterUserApp.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Purchases = APIUser.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchaseist?userid={APIUser.User.Id}");
|
||||
ViewBag.Purchases = APIUser.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchaselist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -173,9 +173,9 @@ namespace AutoCenterUserApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Purchases = APIUser.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchaseist?userid={APIUser.User.Id}");
|
||||
ViewBag.Purchases = APIUser.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchaselist?userid={APIUser.User.Id}");
|
||||
ViewBag.Cars = APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist");
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<CarViewModel>>($"api/presellignwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<CarViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ namespace AutoCenterUserApp.Controllers
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/student/updatepurchase", new PurchaseBindingModel
|
||||
APIUser.PostRequest("api/purchase/updatepurchase", new PurchaseBindingModel
|
||||
{
|
||||
Id = purchaseId,
|
||||
IsCashPaid = isCashPaid,
|
||||
@ -283,7 +283,7 @@ namespace AutoCenterUserApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Wishes = APIUser.GetRequest<List<WishViewModel>>($"api/wish/getwishlist");
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<PresellingWorkViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
@ -322,7 +322,7 @@ namespace AutoCenterUserApp.Controllers
|
||||
return result;
|
||||
}
|
||||
|
||||
// PresellingWork
|
||||
// PresellingWorks
|
||||
public IActionResult PresellingWork()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
@ -427,6 +427,212 @@ namespace AutoCenterUserApp.Controllers
|
||||
|
||||
return result;
|
||||
}
|
||||
// Cars
|
||||
public IActionResult Car()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist"));
|
||||
}
|
||||
|
||||
public IActionResult CreateCar()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Equipments = APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateCar(string name, List<int> equipments)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
|
||||
APIUser.PostRequest("api/car/createcar", new CarBindingModel
|
||||
{
|
||||
Name = name,
|
||||
CarEquipments = equipments.ToDictionary(record => record, record => new EquipmentSearchModel { Id = record } as IEquipmentModel)
|
||||
});
|
||||
Response.Redirect("Car");
|
||||
}
|
||||
public IActionResult DeleteCar()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cars = APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist");
|
||||
return View();
|
||||
}
|
||||
public IActionResult UpdateCar()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Cars = APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist");
|
||||
ViewBag.Equipments = APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteCar(int carId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIUser.PostRequest("api/car/deletecar", new CarBindingModel
|
||||
{
|
||||
Id = carId
|
||||
});
|
||||
Response.Redirect("Car");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateCar(int carId, string name, List<int> equipments)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/car/updatecar", new CarBindingModel
|
||||
{
|
||||
Id = carId,
|
||||
Name = name,
|
||||
CarEquipments = equipments.ToDictionary(record => record, record => new EquipmentSearchModel { Id = record } as IEquipmentModel)
|
||||
});
|
||||
Response.Redirect("Car");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public PresellingWorkViewModel? GetCar(int carId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIUser.GetRequest<PresellingWorkViewModel>($"api/car/getcar?carid={carId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
// Equipments
|
||||
public IActionResult Equipment()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist"));
|
||||
}
|
||||
|
||||
public IActionResult CreateEquipment()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateEquipment(string name, string description)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
|
||||
APIUser.PostRequest("api/equipment/createequipment", new EquipmentBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Description = description
|
||||
});
|
||||
Response.Redirect("Equipment");
|
||||
}
|
||||
public IActionResult DeleteEquipment()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Equipments = APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist");
|
||||
return View();
|
||||
}
|
||||
public IActionResult UpdateEquipment()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Equipments = APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteEquipment(int equipmentId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIUser.PostRequest("api/equipment/deleteequipment", new EquipmentBindingModel
|
||||
{
|
||||
Id = equipmentId
|
||||
});
|
||||
Response.Redirect("Equipment");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateEquipment(int equipmentId, string name, string description)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/equipment/updateequipment", new EquipmentBindingModel
|
||||
{
|
||||
Id = equipmentId,
|
||||
Name = name,
|
||||
Description = description
|
||||
});
|
||||
Response.Redirect("Equipment");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public EquipmentViewModel? GetEquipment(int equipmentId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIUser.GetRequest<EquipmentViewModel>($"api/equipment/getequipment?equipmentid={equipmentId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
|
@ -1,9 +1,9 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateCertification";
|
||||
ViewData["Title"] = "CreateСфк";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание аттестации</h2>
|
||||
<h2 class="display-4">Создание машины</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
@ -15,7 +15,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Комплектации:</div>
|
||||
<div class="col-8">
|
||||
<select name="equipments" class="form-control" multiple size="5" id="equipments" asp-items="@(new SelectList(@ViewBag.Eqipment,"Id", "Name" ))" required></select>
|
||||
<select name="equipments" class="form-control" multiple size="5" id="equipments" asp-items="@(new SelectList(@ViewBag.Equipments,"Id", "Name" ))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Машина:</div>
|
||||
<div class="col-8">
|
||||
<select id="car" name="carId" class="form-control" asp-items="@ViewBag.Cars" required></select>
|
||||
<select id="car" name="carId" class="form-control" asp-items="@(new SelectList(@ViewBag.Cars, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Комплектация:</div>
|
||||
<div class="col-8">
|
||||
<select id="equipment" name="equipmentId" class="form-control" asp-items="@ViewBag.Equipments" required></select>
|
||||
<select id="equipment" name="equipmentId" class="form-control" asp-items="@(new SelectList(@ViewBag.Equipments, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Препродажная работа:</div>
|
||||
<div class="col-8">
|
||||
<select id="presellingWork" name="presellingWorkId" class="form-control" asp-items="@ViewBag.PresellingWorks" required></select>
|
||||
<select id="presellingWork" name="presellingWorkId" class="form-control" asp-items="@(new SelectList(@ViewBag.PresellingWorks, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Покупка:</div>
|
||||
<div class="col-8">
|
||||
<select id="purchase" name="purchaseId" class="form-control" asp-items="@ViewBag.Purchases" required></select>
|
||||
<select id="purchase" name="purchaseId" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchases, "Id", "Date"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Пожелание:</div>
|
||||
<div class="col-8">
|
||||
<select id="wish" name="wishId" class="form-control" asp-items="@ViewBag.Wishes" required></select>
|
||||
<select id="wish" name="wishId" class="form-control" asp-items="@(new SelectList(@ViewBag.Wishes, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -14,9 +14,9 @@
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreateWish">Создать Комплектацию</a>
|
||||
<a asp-action="UpdateWish">Обновить Комплектацию</a>
|
||||
<a asp-action="DeleteWish">Удалить Комплектацию</a>
|
||||
<a asp-action="CreateEquipment">Создать Комплектацию</a>
|
||||
<a asp-action="UpdateEquipment">Обновить Комплектацию</a>
|
||||
<a asp-action="DeleteEquipment">Удалить Комплектацию</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -14,9 +14,9 @@
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreateCertification">Создать предпродажную работу</a>
|
||||
<a asp-action="UpdateCertification">Обновить предпродажную работу</a>
|
||||
<a asp-action="DeleteCertification">Удалить предпродажную работу</a>
|
||||
<a asp-action="CreatePresellingWork">Создать предпродажную работу</a>
|
||||
<a asp-action="UpdatePresellingWork">Обновить предпродажную работу</a>
|
||||
<a asp-action="DeletePresellingWork">Удалить предпродажную работу</a>
|
||||
<a asp-action="PresellingWorkWish">Связать пожелание и предродажюную работу</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
|
@ -10,7 +10,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Предпродажная работа:</div>
|
||||
<div class="col-8">
|
||||
<select id="presellingWork" name="presellingWorkId" class="form-control" asp-items="@ViewBag.PresellingWorks" required></select>
|
||||
<select id="presellingWork" name="presellingWorkId" class="form-control" asp-items="@(new SelectList(@ViewBag.PresellingWorks, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Покупка:</div>
|
||||
<div class="col-8">
|
||||
<select id="purchaseId" name="purchaseId" class="form-control" asp-items="@ViewBag.Purchases" required></select>
|
||||
<select id="purchaseId" name="purchaseId" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchases, "Id", "Date"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -13,7 +13,7 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Университет</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Автоцентр</a>
|
||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -21,13 +21,19 @@
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Студенты</a>
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Car">Машины</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="EducationPlans">Планы обучения</a>
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Покупки</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Certifications">Аттестации</a>
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Wish">Пожелания</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="PresellingWork">Предпродажные работы</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Equipment">Комплектации</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="TeacherListReport">Выгрузка списка</a>
|
||||
@ -56,7 +62,7 @@
|
||||
</div>
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - Университет - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
© 2024 - Автоцентр - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user