Guest User

Untitled

a guest
Oct 28th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. public ActionResult Index()
  2. {
  3. ProductRepository BlProduct = new ProductRepository();
  4. CustomerRepository BlCustomer = new CustomerRepository();
  5. CustomerLikeRepository BlCusLike = new CustomerLikeRepository();
  6. var username = User.Identity.Name;
  7. var customer = BlCustomer.Where(x => x.Email == username).SingleOrDefault();
  8. var model = new HomeIndexViewModel();
  9. model.Products = BlProduct.Select();
  10. if(customer!=null)
  11. {
  12. model.Customer = customer;
  13. model.CostumerLikes = BlCusLike.Where(l=>l.CustomerId==customer.id).ToList();
  14. }
  15. return View(model);
  16. }
  17.  
  18. public class HomeIndexViewModel
  19. {
  20. public IEnumerable<MySIte.Models.DomainModels.Product> Products { get; set; }
  21. public MySIte.Models.DomainModels.Customer Customer { get; set; }
  22. public IEnumerable<MySIte.Models.DomainModels.CostumersLike> CostumerLikes { get; set; }
  23. }
  24.  
  25. @foreach (var item in Model.Products)
  26. {
  27. <div class="product-thumb clearfix" style="height:100%;">
  28. <a href="@item.id">
  29. @Html.ImageFor(modelItem => item.ImgUrl, new { width = "500" }, "Tulips.jpg", "Files", "UploadImages")
  30. </a>
  31. </div>
  32. <div class="product-info clearfix">
  33. <span class="product-title">@item.Name</span>
  34. <div class="price">
  35. <del>
  36. <span class="regular">$@item.Price.ToPrice()</span>
  37. </del>
  38. <ins>
  39. <span class="amount">$@item.Price</span>
  40. </ins>
  41. </div>
  42. </div>
  43. <div class="add-to-cart text-center">
  44. <a data-toggle="modal" data-target="#@item.id"><i class="fa fa-search"></i> quick view</a>
  45. </div>
  46. @if (Model.Customer.Email==User.Identity.Name)
  47. {
  48. <a href="#" class="addWish like" data-product="@item.id"><i class="fa fa-heart-o" style="color:red;"></i></a>
  49. }
  50. </li>
  51. }
Add Comment
Please, Sign In to add comment