Короче че есть то есть...

This commit is contained in:
Никита Волков 2024-08-29 06:44:09 +04:00
parent 506e1cacaa
commit 48cb2d71aa
10 changed files with 71 additions and 71 deletions

View File

@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace BeautyStudioDatabaseImplement.Migrations
{
[DbContext(typeof(BeautyStudioDatabase))]
[Migration("20240828201810_ThirdMig")]
partial class ThirdMig
[Migration("20240829021006_Mig")]
partial class Mig
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace BeautyStudioDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class ThirdMig : Migration
public partial class Mig : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)

View File

@ -55,7 +55,7 @@ namespace BeautyStudioDatabaseImplement.Models
Id = Id,
TimeSpent = TimeSpent,
Difficulty = Difficulty,
StoreKeeperId = StoreKeeper.Id
StoreKeeperId = StoreKeeperId
};
}

View File

@ -90,7 +90,7 @@ namespace BeautyStudioRestAPI.Controllers
}
}
[HttpPost]
[HttpDelete]
public void Delete(CosmeticBindingModel model)
{
try

View File

@ -104,7 +104,7 @@ namespace BeautyStudioRestAPI.Controllers
}
}
[HttpPost]
[HttpDelete]
public void Delete(LaborCostBindingModel model)
{
try

View File

@ -104,7 +104,7 @@ namespace BeautyStudioRestAPI.Controllers
}
}
[HttpPost]
[HttpDelete]
public void Delete(OrderBindingModel model)
{
try

View File

@ -90,7 +90,7 @@ namespace BeautyStudioRestAPI.Controllers
}
}
[HttpPost]
[HttpDelete]
public void Delete(ProcedureBindingModel model)
{
try

View File

@ -104,7 +104,7 @@ namespace BeautyStudioRestAPI.Controllers
}
}
[HttpPost]
[HttpDelete]
public void Delete(ServiceBindingModel model)
{
try

View File

@ -2,6 +2,7 @@
using BeautyStudioContracts.BusinessLogicContracts;
using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.ViewModels;
using BeautyStudioDatabaseImplement;
using BeautyStudioDatabaseImplement.Models;
using BeautyStudioDataModels.Models;
using DocumentFormat.OpenXml.Spreadsheet;
@ -55,7 +56,7 @@ namespace StoreKeeperWebApp.Controllers
}
[HttpGet]
public IActionResult CreateCosmetics()
public IActionResult CreateCosmetics(int laborCostId)
{
if (APIStoreKeeper.Storekeeper == null)
{
@ -67,35 +68,34 @@ namespace StoreKeeperWebApp.Controllers
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
});
return View();
return View();
}
[HttpPost]
public void CreateCosmetics(string name, double price, int laborCost)
{
if (APIStoreKeeper.Storekeeper == null)
{
throw new Exception("Необходимо авторизоваться!");
}
[HttpPost]
public void CreateCosmetics(string name, double price, int laborCost)
{
if (APIStoreKeeper.Storekeeper == null)
{
throw new Exception("Необходимо авторизоваться!");
}
if (string.IsNullOrEmpty(name) || price <= 0 || laborCost <= 0)
{
if (string.IsNullOrEmpty(name) || price <= 0 || laborCost <= 0)
{
throw new Exception("Введены не все данные!");
}
}
cosmetic.Create(new CosmeticBindingModel
{
CosmeticName = name,
CosmeticPrice = price,
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
LaborCostId = laborCost
});
cosmetic.Create(new CosmeticBindingModel
{
CosmeticName = name,
CosmeticPrice = price,
StoreKeeperId = APIStoreKeeper.Storekeeper.Id,
LaborCostId = laborCost
});
Response.Redirect("/Cosmetic/Cosmetics");
}
Response.Redirect("/Cosmetic/Cosmetics");
}
[HttpGet]
[HttpGet]
public IActionResult UpdateCosmetics(int id)
{
if (APIStoreKeeper.Storekeeper == null)

View File

@ -71,50 +71,50 @@ namespace StoreKeeperWebApp.Controllers
return View();
}
[HttpPost]
public void CreateLaborCosts(int hours, string difficulty, int cosmeticId)
{
if (APIStoreKeeper.Storekeeper == null)
{
throw new Exception("Необходимо авторизоваться!");
}
if (hours <= 0 || string.IsNullOrEmpty(difficulty) || cosmeticId <= 0)
{
throw new Exception("Введены не все данные!");
}
laborCost.Create(new LaborCostBindingModel
{
TimeSpent = hours,
Difficulty = difficulty,
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
});
var labor = laborCost.ReadElement(new LaborCostSearchModel {
TimeSpent = hours,
Difficulty = difficulty,
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
});
var cosm = cosmetic.ReadElement(new CosmeticSearchModel{ Id = cosmeticId });
if (cosm != null && labor != null)
[HttpPost]
public void CreateLaborCosts(int hours, string difficulty, int cosmeticId)
{
if (APIStoreKeeper.Storekeeper == null)
{
cosm.LaborCostId = labor.Id; // Присваиваем айди трудозатраты к объекту косметики
cosmetic.Update(new CosmeticBindingModel
{
Id = cosm.Id,
CosmeticName = cosm.CosmeticName,
CosmeticPrice = cosm.CosmeticPrice,
LaborCostId = cosm.LaborCostId
});
throw new Exception("Необходимо авторизоваться!");
}
Response.Redirect("/LaborCost/LaborCosts");
}
if (hours <= 0 || string.IsNullOrEmpty(difficulty) || cosmeticId <= 0)
{
throw new Exception("Введены не все данные!");
}
laborCost.Create(new LaborCostBindingModel
{
TimeSpent = hours,
Difficulty = difficulty,
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
});
[HttpGet]
var labor = laborCost.ReadElement(new LaborCostSearchModel
{
TimeSpent = hours,
Difficulty = difficulty,
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
});
var cosm = cosmetic.ReadElement(new CosmeticSearchModel { Id = cosmeticId });
if (cosm != null && labor != null)
{
cosm.LaborCostId = labor.Id; // Присваиваем айди трудозатраты к объекту косметики
cosmetic.Update(new CosmeticBindingModel
{
Id = cosm.Id,
CosmeticName = cosm.CosmeticName,
CosmeticPrice = cosm.CosmeticPrice,
LaborCostId = cosm.LaborCostId
});
}
Response.Redirect("/LaborCost/LaborCosts");
}
[HttpGet]
public IActionResult UpdateLaborCosts(int id)
{
if (APIStoreKeeper.Storekeeper == null)