Skip to content

Commit

Permalink
work 07.03.2018
Browse files Browse the repository at this point in the history
  • Loading branch information
alinperghel committed Mar 7, 2018
1 parent b56ddc0 commit a163532
Show file tree
Hide file tree
Showing 45 changed files with 380 additions and 69 deletions.
Binary file modified TyresStore/.vs/TyresStore/v15/.suo
Binary file not shown.
Binary file modified TyresStore/.vs/TyresStore/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file not shown.
Empty file.
51 changes: 51 additions & 0 deletions TyresStore/TyresStore.Repository/BasketRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TyresStore.Repository.Interfaces;
using TyresStore.Repository.Models;

namespace TyresStore.Repository
{
public class BasketRepository : IBasketRepository
{
TyresStoreContext tyresContext = new TyresStoreContext();

public void StoreTyre(int tyreId, string brand, string season, string article, double price)
{
Basket item = new Basket();

item.TyreId = tyreId;
item.Brand = brand;
item.Season = season;
item.ArticleCode = article;
item.Price = price;
item.AddedDate = new DateTime().ToShortDateString();

tyresContext.BasketItems.Add(item);
tyresContext.SaveChanges();
}

public List<Basket> GetItems()
{
return tyresContext.BasketItems.ToList();
}

public bool TyreAlreadyAdded(int tyreId)
{
List<Basket> items = this.GetItems();
var item = items.SingleOrDefault(x => x.TyreId == tyreId);

return item != null;
}

public void RemoveItem(int itemId)
{
var item = tyresContext.BasketItems.SingleOrDefault(x => x.ID == itemId);

tyresContext.BasketItems.Remove(item);
tyresContext.SaveChanges();
}
}
}
20 changes: 20 additions & 0 deletions TyresStore/TyresStore.Repository/Interfaces/IBasketRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TyresStore.Repository.Models;

namespace TyresStore.Repository.Interfaces
{
public interface IBasketRepository
{
void StoreTyre(int tyreId, string brand, string season, string article, double price);

List<Basket> GetItems();

bool TyreAlreadyAdded(int tyreId);

void RemoveItem(int itemId);
}
}

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,22 @@
namespace TyresStore.Repository.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class initialmigration : DbMigration
{
public override void Up()
{
AddColumn("dbo.Basket", "Season", c => c.String());
AddColumn("dbo.Basket", "Price", c => c.Double(nullable: false));
AddColumn("dbo.Basket", "ArticleCode", c => c.String());
}

public override void Down()
{
DropColumn("dbo.Basket", "ArticleCode");
DropColumn("dbo.Basket", "Price");
DropColumn("dbo.Basket", "Season");
}
}
}
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>H4sIAAAAAAAEAO1ZS2/jNhC+F+h/EHRqi6yVx6UN7F1knaQwunkgyi7aU8BIY4coRaokFdgo+st66E/qX+hQomTqYVuO6+yiKHyxSc43D84MZ8Z///nX8N08Yd4zSEUFH/lHg0PfAx6JmPLZyM/09M33/ru3X381vIiTufepPHdiziElVyP/Sev0NAhU9AQJUYOERlIoMdWDSCQBiUVwfHj4Q3B0FABC+IjlecO7jGuaQP4Df44FjyDVGWFXIgam7DruhDmqd00SUCmJYOTfLySoUAsJgztIhaL4deF7Z4wSFCYENvU9wrnQRKOopx8VhFoKPgtTXCDsfpECnpsSpsCqcLo83lebw2OjTbAkLKGiTGmRbAl4dGLNEzTJX2RkvzIfGvACDa0XRuvciIX9fK/J6HTMpDm0wr6D4l4GZvPA6zxyUHkHOpH5HHjjjOlMwohDpiVhB95t9sho9BMs7sWvwEc8Y8wVFsXFvdoCLt1KkYLUizuYWhUm574X1OmCJmFF5tAUCk64Pjn2vWtkTh4ZVL7gGCPX7UfgIImG+JZoDRKvchJDbs0W9wavT/BEIwaTeBPL9TDvJeEVBDoxhqTvXZH5B+Az/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Xwd0Ky6/TbpLlSlf4JUtKOpe8vWO3OapHPWt1+joJ2y+X56yxg12t8XYrTa+rS2eF35Ab3Ea5tFsw9atatJesm3D7F7HW17CbsL1robqptry1t265blWL2Usmu34swKK2/FSIfJJ2vIPSfDDn4pXAsxkz4LMqJUbEoH1JN5KBIgLGqd2a9Q2C3D1Kmb50fCUtwyHl4D8GEXycqThROGcJ7VnpR1uxapz8t15dtHl6nR0n5FFNAMylOAa75u4SyoLD7omH7b4HQtDXbrV5Lpbfd+bJAuop4RyDjviLb3EEYMwST13xKHmEb2z5IeA9z4i/z6207yOaFKLt9eEbJXJBQGoyVPP7EGA7CxZv/AYD++MFdKwAA</value>
</data>
<data name="DefaultSchema" xml:space="preserve">
<value>dbo</value>
Expand Down
22 changes: 22 additions & 0 deletions TyresStore/TyresStore.Repository/Models/Basket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;

namespace TyresStore.Repository.Models
{
public class Basket
{
[Key]
public int ID { get; set; }
public string Brand { get; set; }
public string Season { get; set; }
public double Price { get; set; }
public string ArticleCode { get; set; }
public int TyreId { get; set; }
public string AddedDate { get; set; }
public string Description { get; set; }
}
}
13 changes: 8 additions & 5 deletions TyresStore/TyresStore.Repository/TyresStore.Repository.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BasketRepository.cs" />
<Compile Include="Interfaces\IBasketRepository.cs" />
<Compile Include="Interfaces\ITyresRepository.cs" />
<Compile Include="Interfaces\IVehiclesRepository.cs" />
<Compile Include="Migrations\201802261424055_InitialCreate.cs" />
<Compile Include="Migrations\201802261424055_InitialCreate.Designer.cs">
<DependentUpon>201802261424055_InitialCreate.cs</DependentUpon>
<Compile Include="Migrations\201803071054135_initial migration.cs" />
<Compile Include="Migrations\201803071054135_initial migration.Designer.cs">
<DependentUpon>201803071054135_initial migration.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Models\Basket.cs" />
<Compile Include="Models\Tyre.cs" />
<Compile Include="Models\Vehicle.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand All @@ -67,8 +70,8 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Migrations\201802261424055_InitialCreate.resx">
<DependentUpon>201802261424055_InitialCreate.cs</DependentUpon>
<EmbeddedResource Include="Migrations\201803071054135_initial migration.resx">
<DependentUpon>201803071054135_initial migration.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
1 change: 1 addition & 0 deletions TyresStore/TyresStore.Repository/TyresStoreContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public TyresStoreContext() : base("name=TyresStoreContext")

public DbSet<Tyre> Tyres { get; set; }
public DbSet<Vehicle> Vehicles { get; set; }
public DbSet<Basket> BasketItems { get; set; }

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3e20d23ae8da9febb50051682401c61d6db56645
ad579cdc6dbff24b606780f9ebc702e7bf8af202
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\bin\Debug\EntityFram
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\bin\Debug\EntityFramework.SqlServer.dll
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\bin\Debug\EntityFramework.xml
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\bin\Debug\EntityFramework.SqlServer.xml
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\obj\Debug\TyresStore.Repository.csprojResolveAssemblyReference.cache
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\obj\Debug\TyresStore.Repository.Migrations.InitialCreate.resources
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\obj\Debug\TyresStore.Repository.csproj.GenerateResource.Cache
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\obj\Debug\TyresStore.Repository.csproj.CoreCompileInputs.cache
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\obj\Debug\TyresStore.Repository.dll
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\obj\Debug\TyresStore.Repository.pdb
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\obj\Debug\TyresStore.Repository.csprojResolveAssemblyReference.cache
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\obj\Debug\TyresStore.Repository.Migrations.initialmigration.resources
D:\DVSE\Projects\TyreStore\TyresStore\TyresStore.Repository\obj\Debug\TyresStore.Repository.csproj.GenerateResource.Cache
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion TyresStore/TyresStore/App_Start/BundleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ public static void RegisterBundles(BundleCollection bundles)

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
"~/Content/site.css",
"~/Content/colorbox.css"
));

bundles.Add(new ScriptBundle("~/bundles/customScripts").Include(
"~/Scripts/jquery.colorbox-min.js",
"~/Scripts/client/handlers.js",
"~/Scripts/client/MainModel.js",
"~/Scripts/client/basketModel.js"
Expand Down
10 changes: 10 additions & 0 deletions TyresStore/TyresStore/Content/Site.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,14 @@ textarea {

.half{
width: 49% !important;
}

.cart-button {
width: calc(15%-20px);
float: right;
height: 100%;
display: inline-block;
font-size: 1.1em;
color: white;
vertical-align:middle;
}
66 changes: 66 additions & 0 deletions TyresStore/TyresStore/Content/colorbox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Colorbox Core Style:
The following CSS is consistent between example themes and should not be altered.
*/
#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden; -webkit-transform: translate3d(0,0,0);}
#cboxWrapper {max-width:none;}
#cboxOverlay{position:fixed; width:100%; height:100%;}
#cboxMiddleLeft, #cboxBottomLeft{clear:left;}
#cboxContent{position:relative;}
#cboxLoadedContent{overflow:auto; -webkit-overflow-scrolling: touch;}
#cboxTitle{margin:0;}
#cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;}
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
.cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
.cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;}
#colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}

/*
User Style:
Change the following styles to modify the appearance of Colorbox. They are
ordered & tabbed in a way that represents the nesting of the generated HTML.
*/
#cboxOverlay{background:#fff; opacity: 0.9; filter: alpha(opacity = 90);}
#colorbox{outline:0;}
#cboxTopLeft{width:25px; height:25px; background:url(images/border1.png) no-repeat 0 0;}
#cboxTopCenter{height:25px; background:url(images/border1.png) repeat-x 0 -50px;}
#cboxTopRight{width:25px; height:25px; background:url(images/border1.png) no-repeat -25px 0;}
#cboxBottomLeft{width:25px; height:25px; background:url(images/border1.png) no-repeat 0 -25px;}
#cboxBottomCenter{height:25px; background:url(images/border1.png) repeat-x 0 -75px;}
#cboxBottomRight{width:25px; height:25px; background:url(images/border1.png) no-repeat -25px -25px;}
#cboxMiddleLeft{width:25px; background:url(images/border2.png) repeat-y 0 0;}
#cboxMiddleRight{width:25px; background:url(images/border2.png) repeat-y -25px 0;}
#cboxContent{background:#fff; overflow:hidden;}
.cboxIframe{background:#fff;}
#cboxError{padding:50px; border:1px solid #ccc;}
#cboxLoadedContent{margin-bottom:20px;}
#cboxTitle{position:absolute; bottom:0px; left:0; text-align:center; width:100%; color:#999;}
#cboxCurrent{position:absolute; bottom:0px; left:100px; color:#999;}
#cboxLoadingOverlay{background:#fff url(images/loading.gif) no-repeat 5px 5px;}

/* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */
#cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {border:0; padding:0; margin:0; overflow:visible; width:auto; background:none; }

/* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */
#cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;}

#cboxSlideshow{position:absolute; bottom:0px; right:42px; color:#444;}
#cboxPrevious{position:absolute; bottom:0px; left:0; color:#444;}
#cboxNext{position:absolute; bottom:0px; left:63px; color:#444;}
#cboxClose{position:absolute; bottom:0; right:0; display:block; color:#444;}

/*
The following fixes a problem where IE7 and IE8 replace a PNG's alpha transparency with a black fill
when an alpha filter (opacity change) is set on the element or ancestor element. This style is not applied to or needed in IE9.
See: http://jacklmoore.com/notes/ie-transparency-problems/
*/
.cboxIE #cboxTopLeft,
.cboxIE #cboxTopCenter,
.cboxIE #cboxTopRight,
.cboxIE #cboxBottomLeft,
.cboxIE #cboxBottomCenter,
.cboxIE #cboxBottomRight,
.cboxIE #cboxMiddleLeft,
.cboxIE #cboxMiddleRight {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
}
Binary file added TyresStore/TyresStore/Content/images/border1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TyresStore/TyresStore/Content/images/border2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TyresStore/TyresStore/Content/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions TyresStore/TyresStore/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class HomeController : Controller
{
VehiclesRepository vehiclesRepo = new VehiclesRepository();
TyresRepository tyresRepo = new TyresRepository();
BasketRepository basketRepo = new BasketRepository();

public ActionResult Index()
{
Expand All @@ -29,6 +30,36 @@ public string GetTyres(int vehicleId)
return ret;
}

public string GetBasketHtml()
{
List<Basket> basket = basketRepo.GetItems();
string ret = RenderPartialViewToString("~/Views/Home/BasketView.cshtml", basket);
return ret;
}

public string RemoveItemFromBasket(int itemId)
{
basketRepo.RemoveItem(itemId);

return GetBasketHtml();
}

public ActionResult AddTyreToBasket(int tyreId, string brand, string season, string article, double price )
{
bool tyreAdded = basketRepo.TyreAlreadyAdded(tyreId);

if (!tyreAdded)
{
basketRepo.StoreTyre(tyreId, brand, season, article, price);
}
return Json(new { exists = tyreAdded });
}

public ActionResult GetBasketItems()
{
return Json(basketRepo.GetItems(), JsonRequestBehavior.AllowGet);
}

public ActionResult About()
{
ViewBag.Message = "Your application description page.";
Expand Down
Loading

0 comments on commit a163532

Please sign in to comment.