Compare commits
3 Commits
Models
...
business-l
Author | SHA1 | Date | |
---|---|---|---|
|
5a0c5411a8 | ||
|
438bffb502 | ||
|
0692b6671b |
@@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.31019.35
|
VisualStudioVersion = 16.0.31019.35
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LuminousSales", "LuminousSales\LuminousSales.csproj", "{0B102226-3EAB-4DA3-9C1F-4053E4FA2232}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuminousSales", "LuminousSales\LuminousSales.csproj", "{0B102226-3EAB-4DA3-9C1F-4053E4FA2232}"
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "Models\Models.csproj", "{40C482BF-B9C4-4460-BB1C-5A90959D1838}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -17,10 +15,6 @@ Global
|
|||||||
{0B102226-3EAB-4DA3-9C1F-4053E4FA2232}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0B102226-3EAB-4DA3-9C1F-4053E4FA2232}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0B102226-3EAB-4DA3-9C1F-4053E4FA2232}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0B102226-3EAB-4DA3-9C1F-4053E4FA2232}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{0B102226-3EAB-4DA3-9C1F-4053E4FA2232}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0B102226-3EAB-4DA3-9C1F-4053E4FA2232}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{40C482BF-B9C4-4460-BB1C-5A90959D1838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{40C482BF-B9C4-4460-BB1C-5A90959D1838}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{40C482BF-B9C4-4460-BB1C-5A90959D1838}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{40C482BF-B9C4-4460-BB1C-5A90959D1838}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@@ -6,7 +6,5 @@ namespace LuminousSales.Business
|
|||||||
{
|
{
|
||||||
public class DealsBusiness
|
public class DealsBusiness
|
||||||
{
|
{
|
||||||
private DealContext dealContext;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,5 @@ namespace LuminousSales.Business
|
|||||||
{
|
{
|
||||||
public class PermissionsBusiness
|
public class PermissionsBusiness
|
||||||
{
|
{
|
||||||
private PermissionContext permissionContext;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,66 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using LuminousSales.Data;
|
|
||||||
using LuminousSales.Data.Model;
|
|
||||||
|
|
||||||
namespace LuminousSales.Business
|
namespace LuminousSales.Business
|
||||||
{
|
{
|
||||||
public class ProductBusiness
|
public class ProductBusiness
|
||||||
{
|
{
|
||||||
private ProductContext productContext;
|
|
||||||
|
|
||||||
public List<Product> GetAll()
|
|
||||||
{
|
|
||||||
using (productContext = new ProductContext())
|
|
||||||
{
|
|
||||||
return productContext.Products.ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Product Get(int id)
|
|
||||||
{
|
|
||||||
using (productContext = new ProductContext())
|
|
||||||
{
|
|
||||||
return productContext.Products.Find(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Buy(Product product)
|
|
||||||
{
|
|
||||||
using (productContext = new ProductContext())
|
|
||||||
{
|
|
||||||
productContext.Products.Add(product);
|
|
||||||
productContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(Product product)
|
|
||||||
{
|
|
||||||
using (productContext = new ProductContext())
|
|
||||||
{
|
|
||||||
var item = productContext.Products.Find(product.Id);
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
productContext.Entry(item).CurrentValues.SetValues(product);
|
|
||||||
productContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Sell(int id)
|
|
||||||
{
|
|
||||||
using (productContext = new ProductContext())
|
|
||||||
{
|
|
||||||
var product = productContext.Products.Find(id);
|
|
||||||
if (product != null)
|
|
||||||
{
|
|
||||||
productContext.Products.Remove(product);
|
|
||||||
productContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,5 @@ namespace LuminousSales.Business
|
|||||||
{
|
{
|
||||||
public class RolesBusiness
|
public class RolesBusiness
|
||||||
{
|
{
|
||||||
private RoleContext roleContext;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,5 @@ namespace LuminousSales.Business
|
|||||||
{
|
{
|
||||||
public class RolesToPermissionBusiness
|
public class RolesToPermissionBusiness
|
||||||
{
|
{
|
||||||
private RolesToPermissionContext rolesToPermissionContext;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,5 @@ namespace LuminousSales.Business
|
|||||||
{
|
{
|
||||||
public class StocksBusiness
|
public class StocksBusiness
|
||||||
{
|
{
|
||||||
private StockContext stockContext;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,5 @@ namespace LuminousSales.Business
|
|||||||
{
|
{
|
||||||
public class UsersBusiness
|
public class UsersBusiness
|
||||||
{
|
{
|
||||||
private UserContext userContext;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,6 @@ namespace LuminousSales.Business
|
|||||||
{
|
{
|
||||||
public class UsersToRolesBusiness
|
public class UsersToRolesBusiness
|
||||||
{
|
{
|
||||||
private UsersToRolesContext usersToRolesContext;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,9 +6,5 @@ namespace LuminousSales.Data.Model
|
|||||||
{
|
{
|
||||||
public class Product
|
public class Product
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public decimal Price { get; set; }
|
|
||||||
public int AmountInStock { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Entity;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using LuminousSales.Data.Model;
|
|
||||||
|
|
||||||
namespace LuminousSales.Data
|
namespace LuminousSales.Data
|
||||||
{
|
{
|
||||||
public class ProductContext : DbContext
|
public class ProductContext
|
||||||
{
|
{
|
||||||
public ProductContext():base("name = ProductContext")
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public DbSet<Product> Products { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@ namespace LuminousSales
|
|||||||
{
|
{
|
||||||
int a = int.Parse(Console.ReadLine());
|
int a = int.Parse(Console.ReadLine());
|
||||||
Console.WriteLine(a);
|
Console.WriteLine(a);
|
||||||
|
Console.WriteLine("Jazcurka");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,23 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Models.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Models
|
|
||||||
{
|
|
||||||
class LuminousContext : DbContext
|
|
||||||
{
|
|
||||||
public LuminousContext(): base("name=LuminousContext")
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public DbSet<User> User { get; set; }
|
|
||||||
public DbSet<Role> Role { get; set; }
|
|
||||||
public DbSet<Permission> Permission { get; set; }
|
|
||||||
public DbSet<Product> Product { get; set; }
|
|
||||||
public DbSet<Deal> Deal{ get; set; }
|
|
||||||
public DbSet<Stock> Stock { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,11 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.12" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@@ -1,15 +0,0 @@
|
|||||||
using Models.Models.Interfaces;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Models.Models
|
|
||||||
{
|
|
||||||
public class Deal : IBaseSalesProperties
|
|
||||||
{
|
|
||||||
public User User { get; set; }
|
|
||||||
public ICollection<Product> ProductsADeal { get; set; }
|
|
||||||
public double Amount { get; set; }
|
|
||||||
[Timestamp]
|
|
||||||
public byte[] Time { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Models.Models.Interfaces
|
|
||||||
{
|
|
||||||
public interface IBaseProperties
|
|
||||||
{
|
|
||||||
int Id { get; set; }
|
|
||||||
string Name { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Models.Models.Interfaces
|
|
||||||
{
|
|
||||||
interface IBaseSalesProperties
|
|
||||||
{
|
|
||||||
User User { get; set; }
|
|
||||||
ICollection<Product> ProductsADeal { get; set;}
|
|
||||||
double Amount { get; set; }
|
|
||||||
public byte[] Time { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,11 +0,0 @@
|
|||||||
using Models.Models.Interfaces;
|
|
||||||
|
|
||||||
namespace Models.Models
|
|
||||||
{
|
|
||||||
public class Permission : IBaseProperties
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
using Models.Models.Interfaces;
|
|
||||||
|
|
||||||
namespace Models.Models
|
|
||||||
{
|
|
||||||
public class Product : IBaseProperties
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public double Price { get; set; }
|
|
||||||
public double AvailableInStock { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,14 +0,0 @@
|
|||||||
using Models.Models.Interfaces;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Models.Models
|
|
||||||
{
|
|
||||||
public class Role : IBaseProperties
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public ICollection<User> UsersWithTheRole { get; set; }
|
|
||||||
public ICollection<Permission> RolesPermissions{ get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
using Models.Models.Interfaces;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Models.Models
|
|
||||||
{
|
|
||||||
class Stock : IBaseSalesProperties
|
|
||||||
{
|
|
||||||
public User User { get; set; }
|
|
||||||
public ICollection<Product> ProductsADeal { get; set; }
|
|
||||||
public double Amount { get; set; }
|
|
||||||
[Timestamp]
|
|
||||||
public byte[] Time { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
using Models.Models.Interfaces;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Models.Models
|
|
||||||
{
|
|
||||||
public class User : IBaseProperties
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Passcode { get; set; }
|
|
||||||
public Role Role { get; set; }
|
|
||||||
public ICollection<Deal> ItemsSoldByUser{ get; set; }
|
|
||||||
public ICollection<Product> ItemsStockedByUser { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user