PIbd-22 Alkin_D.V. LabWork_1 #1

Closed
Darl1ngzxc wants to merge 9 commits from LabWork_1 into main
18 changed files with 337 additions and 8 deletions
Showing only changes of commit abf0876d33 - Show all commits

View File

@ -1,4 +1,5 @@
using System;
using ProjectGasStation.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -12,8 +13,10 @@ public class Employee
public string Name { get; private set; } = string.Empty;
public static Employee CreateEntity(int id, string name)
public EmployeePost EmployeePost { get; private set; }
public static Employee CreateEntity(int id, string name, EmployeePost employeePost)
{
return new Employee { Id = id, Name = name };
return new Employee { Id = id, Name = name ?? string.Empty, EmployeePost = employeePost };
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities.Enums;
[Flags]
public enum EmployeePost
{
None = 0,
Cashier = 1,
Fueler = 2,
Manager = 4,
Programmer = 8,
Mechanic = 16
}

View File

@ -5,12 +5,18 @@ using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities.Enums;
[Flags]
public enum ProductType
{
None = 0,
Fuel = 1,
MotorOil = 2,
AutoChemicals = 3,
AutoParts = 4,
Tires = 5,
}

View File

@ -0,0 +1,24 @@
using ProjectGasStation.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class Product
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public double Price { get; private set; }
public ProductType ProductType { get; private set; }
public static Product CreateEntity(int id, string name, double price, ProductType productType)
{
return new Product { Id = id, Name = name ?? string.Empty, Price = price, ProductType = productType };
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class Purchase
{
public int Id { get; private set; }
public int ProductId { get; private set; }
public int SupplierId { get; private set; }
public double Quantity { get; private set; }
public DateTime PurchaseDate { get; private set; }
public double Price { get; private set; }
public static Purchase CreateElement(int id, int productId, int supplierId, double quantity, DateTime purchaseDate, double price)
{
return new Purchase { Id = id, ProductId = productId, SupplierId = supplierId, Quantity = quantity, PurchaseDate = purchaseDate, Price = price };
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class Sale
{
public int Id { get; private set; }
public int ShiftId { get; private set; }
public double Quantity { get; private set; }
public DateTime SaleDate { get; private set; }
public static Sale CreateElement(int id, int shiftId, double quantity, DateTime saleDate)
{
return new Sale { Id = id, ShiftId = shiftId, Quantity = quantity, SaleDate = saleDate };
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class SaleProduct
{
public int SaleID { get; private set; }
public int ProductID { get; private set;}
public static SaleProduct CreateElement(int saleID, int productID)
{
return new SaleProduct() { SaleID = saleID, ProductID = productID };
}
}

View File

@ -15,4 +15,9 @@ public class Shift
public DateTime DateFinish { get; private set; }
public int EmployeeID { get; private set; }
public static Shift CreateElement(int id, DateTime dateStart, DateTime dateFinish, int employeeID)
{
return new Shift { Id = id, DateStart = dateStart, DateFinish = dateFinish, EmployeeID = employeeID };
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class Supplier
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public string INN { get; private set; } = string.Empty;
public static Supplier CreateElement(int id, string name, string INN)
{
return new Supplier { Id = id, Name = name, INN = INN };
}
}

View File

@ -0,0 +1,37 @@
using ProjectGasStation.Entities;
using ProjectGasStation.Entities.Enums;
using ProjectGasStation.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Implementations;
public class EmployeeRepository : IEmployeeRepository
{
public CreateEmployee(Employee employee)
{
}
public void DeleteEmployee(int id)
{
}
public Employee ReadEmployeeById(int id)
{
return Employee.CreateEntity(0, string.Empty, EmployeePost.None);
}
public IEnumerable<Employee> ReadEmployees()
{
return [];
}
public void UpdateEmployee(Employee employee)
{
}
}

View File

@ -0,0 +1,38 @@
using ProjectGasStation.Entities;
using ProjectGasStation.Entities.Enums;
using ProjectGasStation.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Implementations;
public class ProductRepository : IProductRepository
{
public void CreateProduct(Product product)
{
}
public void DeleteProduct(int id)
{
}
public Product ReadProductById(int id)
{
return Product.CreateEntity(0, string.Empty, 0, ProductType.None);
}
public IEnumerable<Product> ReadProducts()
{
return [];
}
public void UpdateProduct(Product product)
{
}
}

View File

@ -8,8 +8,4 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Folder Include="Entities\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,21 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface IEmployeeRepository
{
IEnumerable<Employee> ReadEmployees();
Employee ReadEmployeeById(int id);
void CreateEmployee(Employee employee);
void UpdateEmployee(Employee employee);
void DeleteEmployee(int id);
}

View File

@ -0,0 +1,21 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface IProductRepository
{
IEnumerable<Product> ReadProducts();
Product ReadProductById(int id);
void CreateProduct(Product product);
void UpdateProduct(Product product);
void DeleteProduct(int id);
}

View File

@ -0,0 +1,15 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface IPurchaseRepository
{
IEnumerable<Purchase> ReadPurchases(DateTime? dateFrom = null, DateTime? dateTo = null, int? supplierId = null, int? productId = null);
void CreatePurchase(Purchase purchase);
}

View File

@ -0,0 +1,15 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface ISaleRepository
{
IEnumerable<Sale> ReadSales(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null, int? shiftId = null);
void CreateSale(Sale sale);
}

View File

@ -0,0 +1,15 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface IShiftRepository
{
IEnumerable<Shift> ReadShifts(DateTime? dateFrom = null, DateTime? dateTo = null, int? employeeId = null);
void CreateShift(Shift shift);
}

View File

@ -0,0 +1,21 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface ISupplierRepository
{
IEnumerable<Supplier> ReadSuppliers();
Supplier ReadSupplierById(int id);
void CreateSupplier(Supplier supplier);
void UpdateSupplier(Supplier supplier);
void DeleteSupplier(int id);
}