Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Index()
- {
- ProductRepository BlProduct = new ProductRepository();
- CustomerRepository BlCustomer = new CustomerRepository();
- CustomerLikeRepository BlCusLike = new CustomerLikeRepository();
- var username = User.Identity.Name;
- var customer = BlCustomer.Where(x => x.Email == username).SingleOrDefault();
- var model = new HomeIndexViewModel();
- model.Products = BlProduct.Select();
- if(customer!=null)
- {
- model.Customer = customer;
- model.CostumerLikes = BlCusLike.Where(l=>l.CustomerId==customer.id).ToList();
- }
- return View(model);
- }
- public class HomeIndexViewModel
- {
- public IEnumerable<MySIte.Models.DomainModels.Product> Products { get; set; }
- public MySIte.Models.DomainModels.Customer Customer { get; set; }
- public IEnumerable<MySIte.Models.DomainModels.CostumersLike> CostumerLikes { get; set; }
- }
- @foreach (var item in Model.Products)
- {
- <div class="product-thumb clearfix" style="height:100%;">
- <a href="@item.id">
- @Html.ImageFor(modelItem => item.ImgUrl, new { width = "500" }, "Tulips.jpg", "Files", "UploadImages")
- </a>
- </div>
- <div class="product-info clearfix">
- <span class="product-title">@item.Name</span>
- <div class="price">
- <del>
- <span class="regular">$@item.Price.ToPrice()</span>
- </del>
- <ins>
- <span class="amount">$@item.Price</span>
- </ins>
- </div>
- </div>
- <div class="add-to-cart text-center">
- <a data-toggle="modal" data-target="#@item.id"><i class="fa fa-search"></i> quick view</a>
- </div>
- @if (Model.Customer.Email==User.Identity.Name)
- {
- <a href="#" class="addWish like" data-product="@item.id"><i class="fa fa-heart-o" style="color:red;"></i></a>
- }
- </li>
- }
Add Comment
Please, Sign In to add comment