Skip to content

16.customer models #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: 16.CustomerModels
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MyShop/MyShop.Core/Contracts/IBasketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public interface IBasketService
void RemoveFromBasket(HttpContextBase httpContext, string itemId);
List<BasketItemViewModel> GetBasketItems(HttpContextBase httpContext);
BasketSummaryViewModel GetBasketSummary(HttpContextBase httpContext);
void ClearBasket(HttpContextBase httpContext);

}
}
18 changes: 18 additions & 0 deletions MyShop/MyShop.Core/Contracts/IOrderService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using MyShop.Core.Models;
using MyShop.Core.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyShop.Core.Contracts
{
public interface IOrderService
{
void CreateOrder(Order baseOrder, List<BasketItemViewModel> basketItems);
List<Order> GetOrderList();
Order GetOrder(string Id);
void UpdateOrder(Order updatedOrder);
}
}
25 changes: 25 additions & 0 deletions MyShop/MyShop.Core/Models/Order.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyShop.Core.Models
{
public class Order : BaseEntity
{
public Order() {
this.OrderItems = new List<OrderItem>();
}

public string FirstName { get; set; }
public string Surname { get; set; }
public string Email { get; set; }
public string Street { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
public string OrderStatus { get; set; }
public virtual ICollection<OrderItem> OrderItems { get; set; }
}
}
18 changes: 18 additions & 0 deletions MyShop/MyShop.Core/Models/OrderItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyShop.Core.Models
{
public class OrderItem : BaseEntity
{
public string OrderId { get; set; }
public string ProductId { get; set; }
public string ProductName { get; set; }
public decimal Price { get; set; }
public string Image { get; set; }
public int Quanity { get; set; }
}
}
3 changes: 3 additions & 0 deletions MyShop/MyShop.Core/MyShop.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Contracts\IBasketService.cs" />
<Compile Include="Contracts\IOrderService.cs" />
<Compile Include="Contracts\IRepository.cs" />
<Compile Include="Models\BaseEntity.cs" />
<Compile Include="Models\Basket.cs" />
<Compile Include="Models\BasketItem.cs" />
<Compile Include="Models\Customer.cs" />
<Compile Include="Models\Order.cs" />
<Compile Include="Models\OrderItem.cs" />
<Compile Include="Models\Product.cs" />
<Compile Include="Models\ProductCategory.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
7 changes: 5 additions & 2 deletions MyShop/MyShop.DataAccess.SQL/DataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace MyShop.DataAccess.SQL
public class DataContext : DbContext
{
public DataContext()
: base("DefaultConnection") {
: base("DefaultConnection")
{

}

Expand All @@ -20,5 +21,7 @@ public DataContext()
public DbSet<Basket> Baskets { get; set; }
public DbSet<BasketItem> BasketItems { get; set; }
public DbSet<Customer> Customers { get; set; }
//public DbSet<Order> Orders { get; set; }
//public DbSet<OrderItem> OrderItems { get; set; }
}
}
}
42 changes: 0 additions & 42 deletions MyShop/MyShop.DataAccess.SQL/Migrations/201711071327340_Initial.cs

This file was deleted.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace MyShop.DataAccess.SQL.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class AddBasket : DbMigration
{
public override void Up()
{
}

public override void Down()
{
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace MyShop.DataAccess.SQL.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class AddCustomer : DbMigration
{
public override void Up()
{
}

public override void Down()
{
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions MyShop/MyShop.DataAccess.SQL/Migrations/202409191228545_Initial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace MyShop.DataAccess.SQL.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class Initial : DbMigration
{
public override void Up()
{
}

public override void Down()
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Target" xml:space="preserve">
<value>H4sIAAAAAAAEAO1ZzW7bRhC+F+g7EDy1gKOVlEMTg0rgSnZh1LKc0Ml9RY6kRZe77O7SkJ6thz5SX6Gz4j8p0ZLspDZQGDDE5cw3/zsz0j9//e19XEfceQClmRQjd9Druw6IQIZMLEduYhZv3rkfP/z4g3cZRmvna0731tIhp9Ajd2VMfE6IDlYQUd2LWKCklgvTC2REaCjJsN9/TwYDAgjhIpbjeJ8TYVgE2wd8HEsRQGwSyqcyBK6zc3zjb1GdWxqBjmkAI3e68Vcy7k2ooRdBAFr3/E83rnPBGUVlfOAL16FCSEMNqnr+RYNvlBRLP8YDyu83MSDdgnINmQnnJfmh1vSH1hpSMuZQQaKNjI4EHLzN3EOa7Cc52S3chw68REebjbV668SRe6dkmARmTA0spdq4TlPm+ZgrS1+4eiwV9NLA9BrcZ06F5qzID0wj+3fmjBNuEgUjAYlRlJ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P+s0EVoMXL/otj/11BKQygV61AMsulQB1BGtKCroRbqsXaCGk4u+3mqDmwb9D5YBsj9Un451UCqh5H/BM6f/kIDJwMi8gov+ao9gu+WQ+ZkpnfhYcKhxlQypbxhUWyIlSrUyQGbIFdEc517hK7RNyw/iS8ICdKb0JRRAKWDL2HtxSyi8KMW3043KIMs/jm3ir59tYArBJoo3uhr4PievkfF/UbGoNEFHs+hVDe6JLCIXgJMsc6dqnHYFS8eUh9x57gQtg/IZa6AmvwxvcRC/xHNnLLH3XDLJaEWWxj88ImjPk8RSjmA+fYMOOt3j7P0sUqHcuOgAA</value>
</data>
<data name="DefaultSchema" xml:space="preserve">
<value>dbo</value>
Expand Down
30 changes: 15 additions & 15 deletions MyShop/MyShop.DataAccess.SQL/MyShop.DataAccess.SQL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DataContext.cs" />
<Compile Include="Migrations\201711071327340_Initial.cs" />
<Compile Include="Migrations\201711071327340_Initial.Designer.cs">
<DependentUpon>201711071327340_Initial.cs</DependentUpon>
<Compile Include="Migrations\202409170922120_AddBasket.cs" />
<Compile Include="Migrations\202409170922120_AddBasket.Designer.cs">
<DependentUpon>202409170922120_AddBasket.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201711091321341_AddBasket.cs" />
<Compile Include="Migrations\201711091321341_AddBasket.Designer.cs">
<DependentUpon>201711091321341_AddBasket.cs</DependentUpon>
<Compile Include="Migrations\202409191004213_AddCustomer.cs" />
<Compile Include="Migrations\202409191004213_AddCustomer.Designer.cs">
<DependentUpon>202409191004213_AddCustomer.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201801032024566_AddCustomer.cs" />
<Compile Include="Migrations\201801032024566_AddCustomer.Designer.cs">
<DependentUpon>201801032024566_AddCustomer.cs</DependentUpon>
<Compile Include="Migrations\202409191228545_Initial.cs" />
<Compile Include="Migrations\202409191228545_Initial.Designer.cs">
<DependentUpon>202409191228545_Initial.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand All @@ -75,14 +75,14 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Migrations\201711071327340_Initial.resx">
<DependentUpon>201711071327340_Initial.cs</DependentUpon>
<EmbeddedResource Include="Migrations\202409170922120_AddBasket.resx">
<DependentUpon>202409170922120_AddBasket.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201711091321341_AddBasket.resx">
<DependentUpon>201711091321341_AddBasket.cs</DependentUpon>
<EmbeddedResource Include="Migrations\202409191004213_AddCustomer.resx">
<DependentUpon>202409191004213_AddCustomer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201801032024566_AddCustomer.resx">
<DependentUpon>201801032024566_AddCustomer.cs</DependentUpon>
<EmbeddedResource Include="Migrations\202409191228545_Initial.resx">
<DependentUpon>202409191228545_Initial.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
6 changes: 6 additions & 0 deletions MyShop/MyShop.Services/BasketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,11 @@ join p in productContext.Collection() on item.ProductId equals p.Id
return model;
}
}

public void ClearBasket(HttpContextBase httpContext) {
Basket basket = GetBasket(httpContext, false);
basket.BasketItems.Clear();
basketContext.Commit();
}
}
}
1 change: 1 addition & 0 deletions MyShop/MyShop.Services/MyShop.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BasketService.cs" />
<Compile Include="OrderService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading