сломалось
This commit is contained in:
parent
9354462a00
commit
72202d2d74
@ -15,7 +15,7 @@ namespace AircraftPlantDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-6QDRI0N\SQLEXPRESS;Initial Catalog=AircraftPlantDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-6QDRI0N\SQLEXPRESS;Initial Catalog=AircraftPlantDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace AircraftPlantDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new AircraftPlantDatabase();
|
using var context = new AircraftPlantDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Plant)
|
.Include(x => x.Plane)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ namespace AircraftPlantDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
using var context = new AircraftPlantDatabase();
|
using var context = new AircraftPlantDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Plant)
|
.Include(x => x.Plane)
|
||||||
.Where(x => x.Id == model.Id)
|
.Where(x => x.Id == model.Id)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -40,7 +40,7 @@ namespace AircraftPlantDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
using var context = new AircraftPlantDatabase();
|
using var context = new AircraftPlantDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Plant)
|
.Include(x => x.Plane)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ namespace AircraftPlantDatabaseImplement.Implements
|
|||||||
context.Orders.Add(newOrder);
|
context.Orders.Add(newOrder);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Plant)
|
.Include(x => x.Plane)
|
||||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ namespace AircraftPlantDatabaseImplement.Implements
|
|||||||
order.Update(model);
|
order.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Plant)
|
.Include(x => x.Plane)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ namespace AircraftPlantDatabaseImplement.Implements
|
|||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
var deletedElement = context.Orders
|
var deletedElement = context.Orders
|
||||||
.Include(x => x.Plant)
|
.Include(x => x.Plane)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
context.Orders.Remove(element);
|
context.Orders.Remove(element);
|
||||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
namespace AircraftPlantDatabaseImplement.Migrations
|
namespace AircraftPlantDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AircraftPlantDatabase))]
|
[DbContext(typeof(AircraftPlantDatabase))]
|
||||||
[Migration("20240326134051_InitialCreate")]
|
[Migration("20240326170504_InitialCreate")]
|
||||||
partial class InitialCreate
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -126,11 +126,13 @@ namespace AircraftPlantDatabaseImplement.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("AircraftPlantDatabaseImplement.Models.Plane", null)
|
b.HasOne("AircraftPlantDatabaseImplement.Models.Plane", "Plane")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("PlaneId")
|
.HasForeignKey("PlaneId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Plane");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.PlaneComponent", b =>
|
modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.PlaneComponent", b =>
|
@ -1,6 +1,8 @@
|
|||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.ViewModels;
|
using AircraftPlantContracts.ViewModels;
|
||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
@ -9,12 +11,16 @@ namespace AircraftPlantDatabaseImplement.Models
|
|||||||
public class Component : IComponentModel
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ComponentId")]
|
[ForeignKey("ComponentId")]
|
||||||
public virtual List<PlaneComponent> PlaneComponents { get; set; } = new();
|
public virtual List<PlaneComponent> PlaneComponents { get; set; } = new();
|
||||||
|
|
||||||
public static Component? Create(ComponentBindingModel model)
|
public static Component? Create(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -28,6 +34,7 @@ namespace AircraftPlantDatabaseImplement.Models
|
|||||||
Cost = model.Cost
|
Cost = model.Cost
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component Create(ComponentViewModel model)
|
public static Component Create(ComponentViewModel model)
|
||||||
{
|
{
|
||||||
return new Component
|
return new Component
|
||||||
@ -37,6 +44,7 @@ namespace AircraftPlantDatabaseImplement.Models
|
|||||||
Cost = model.Cost
|
Cost = model.Cost
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(ComponentBindingModel model)
|
public void Update(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -46,6 +54,7 @@ namespace AircraftPlantDatabaseImplement.Models
|
|||||||
ComponentName = model.ComponentName;
|
ComponentName = model.ComponentName;
|
||||||
Cost = model.Cost;
|
Cost = model.Cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComponentViewModel GetViewModel => new()
|
public ComponentViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
@ -53,4 +62,4 @@ namespace AircraftPlantDatabaseImplement.Models
|
|||||||
Cost = Cost
|
Cost = Cost
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,36 +2,40 @@
|
|||||||
using AircraftPlantContracts.ViewModels;
|
using AircraftPlantContracts.ViewModels;
|
||||||
using AircraftPlantDataModels.Enums;
|
using AircraftPlantDataModels.Enums;
|
||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantDataModels.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AircraftPlantDatabaseImplement.Models
|
namespace AircraftPlantDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int PlaneId { get; set; }
|
public int PlaneId { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public OrderStatus Status { get; set; }
|
public OrderStatus Status { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
|
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
|
||||||
|
public virtual Plane Plane { get; set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Order
|
return new Order()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
PlaneId = model.PlaneId,
|
PlaneId = model.PlaneId,
|
||||||
@ -42,16 +46,17 @@ namespace AircraftPlantDatabaseImplement.Models
|
|||||||
DateImplement = model.DateImplement
|
DateImplement = model.DateImplement
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
public void Update(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
@ -60,7 +65,8 @@ namespace AircraftPlantDatabaseImplement.Models
|
|||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement
|
DateImplement = DateImplement,
|
||||||
|
PlaneName = Plane.PlaneName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -119,7 +119,7 @@ namespace AircraftPlantView
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
private void buttonOrderReady_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ namespace AircraftPlantView
|
|||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
var operationResult = _logic.DeliveryOrder(new OrderBindingModel { Id = id });
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
@ -141,6 +141,7 @@ namespace AircraftPlantView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Заказ выдан"
|
/// Кнопка "Заказ выдан"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user