From deb96d0ec4a93a1aec40e5a84d03a05fe3b2b93a Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 25 Mar 2019 16:55:20 +0700 Subject: [PATCH 01/20] edit home controller and layoutcshtml --- Test/Controllers/HomeController.cs | 27 ++++++++++++++++++++++----- Test/Views/Shared/_Layout.cshtml | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Test/Controllers/HomeController.cs b/Test/Controllers/HomeController.cs index ca398d1..8c0f541 100644 --- a/Test/Controllers/HomeController.cs +++ b/Test/Controllers/HomeController.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Web; @@ -44,11 +45,11 @@ public ActionResult Index() + "\"Card" + "
" + "

" + laptops[i].name + "

" - + "

$" + phones[i].price + "/p>" + + "

$" + phones[i].price + "

" + "
" + "
" + "" - + " Add to cart" + + " Add to cart" + "
" + "
" + "
" @@ -65,13 +66,29 @@ public ActionResult Index() } public ActionResult AddCart(int id) { - Session["CartProductId"] = id; - ViewBag.id = Session["CartProductId"]; + if (Session["CartProductId"] == null) { + ArrayList productsCartNew = new ArrayList(); + productsCartNew.Add(id); + Session["CartProductId"] = productsCartNew; + } + else + { + ArrayList productsCartExisted = Session["CartProductId"] as ArrayList; + productsCartExisted.Add(id); + } + + ViewBag.id = id; return View(); } public ActionResult Cart() { - ViewBag.id = Session["CartProductId"]; + ArrayList productsCartExisted = Session["CartProductId"] as ArrayList; + int total = 0; + foreach (int num in productsCartExisted) + { + total ++; //-->Runtime Error + } + ViewBag.id = total; return View(); } diff --git a/Test/Views/Shared/_Layout.cshtml b/Test/Views/Shared/_Layout.cshtml index 3159363..6e4f0ad 100644 --- a/Test/Views/Shared/_Layout.cshtml +++ b/Test/Views/Shared/_Layout.cshtml @@ -13,7 +13,7 @@
@@ -45,5 +57,6 @@ @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstrap") @RenderSection("scripts", required: false) + From e388b79279b11119e9ca09d724a0c0d2910f5388 Mon Sep 17 00:00:00 2001 From: PC Date: Mon, 25 Mar 2019 21:44:59 +0700 Subject: [PATCH 04/20] View details page - commit 2 --- Test/Content/Site.css | 40 +++++++++++++++++++++ Test/Content/home.css | 11 ++++++ Test/Controllers/HomeController.cs | 4 +-- Test/Views/Home/Index.cshtml | 57 ++++++++++++++++++++++++++++-- Test/Views/Shared/_Layout.cshtml | 55 ++++++++++++++++++++++++---- 5 files changed, 155 insertions(+), 12 deletions(-) diff --git a/Test/Content/Site.css b/Test/Content/Site.css index a13c102..03dd648 100644 --- a/Test/Content/Site.css +++ b/Test/Content/Site.css @@ -129,4 +129,44 @@ textarea { color: #fff; background-color: #303030; text-transform: uppercase; +} + +/*Footer*/ +#myFooter { + background-color: #3c3d41; + color: white; + margin-top: 20px; + padding-top: 30px; + font-size: 20px; + margin-bottom: -20px; +} +.footer-copyright { + background-color: #333333; + padding-top: 3px; + padding-bottom: 3px; + text-align: center; +} +#myFooter .social-networks { + text-align: center; + padding-top: 10px; + padding-bottom: 16px; +} +#myFooter .social-networks a { + color: white; + font-size: 34px; + margin-right: 10px; +} +#myFooter .btn { + color: white; + background-color: #d84b6b; + border-radius: 20px; + cursor: pointer; + border: none; + width: 150px; + display: block; + margin: 10px auto; + line-height: 25px; +} +#myFooter .col-sm-2>ul>li>a { + color: white; } \ No newline at end of file diff --git a/Test/Content/home.css b/Test/Content/home.css index 466485f..234c162 100644 --- a/Test/Content/home.css +++ b/Test/Content/home.css @@ -165,10 +165,21 @@ nav.navbar .collapse ul { img.logo { width: 50px; } +.logo-space { + float:left; + margin-left: -15px; + margin-right: 10px; + margin-top: 5px; +} .body-content{ margin-top:50px; } .oneProduct.card.col-sm-3 img{ width:100%; +} + +.img-fluid { + max-width: 100%; + height: auto; } \ No newline at end of file diff --git a/Test/Controllers/HomeController.cs b/Test/Controllers/HomeController.cs index ef01edf..b24eddc 100644 --- a/Test/Controllers/HomeController.cs +++ b/Test/Controllers/HomeController.cs @@ -19,7 +19,7 @@ public ActionResult Index() for (int i = 0; i < phones.Count; i++) { resultPhones += "
" - +"\"Card" + +"\"Card" +"
" +"

"+ phones[i].name+ "

" + "

$" + phones[i].price + "

" @@ -41,7 +41,7 @@ public ActionResult Index() for (int i = 0; i < laptops.Count; i++) { resultLaptops += "
" - + "\"Card" + + "\"Card" + "
" + "

" + laptops[i].name + "

" + "

$" + phones[i].price + "/p>" diff --git a/Test/Views/Home/Index.cshtml b/Test/Views/Home/Index.cshtml index f8eb449..44918af 100644 --- a/Test/Views/Home/Index.cshtml +++ b/Test/Views/Home/Index.cshtml @@ -5,10 +5,61 @@

-
- Card image cap + -
+
Laptop
diff --git a/Test/Views/Shared/_Layout.cshtml b/Test/Views/Shared/_Layout.cshtml index 676372f..e632715 100644 --- a/Test/Views/Shared/_Layout.cshtml +++ b/Test/Views/Shared/_Layout.cshtml @@ -13,7 +13,7 @@