public ActionResult Index()
        {
            var estates = new List<HomeIndexEstateViewModel>();
            var appliances = new List<HomeIndexApplianceViewModel>();

            if (this.HttpContext.Cache["Home estates"] != null && this.HttpContext.Cache["Home appliances"] != null)
            {
                ViewBag.Estates = this.HttpContext.Cache["Home estates"];
                ViewBag.Appliances = this.HttpContext.Cache["Home appliances"];
            }
            else
            {
                estates = this.estates
                    .GetAll()
                    .OrderByDescending(e => e.Ratings.Count() == 0 ? 0 : e.Ratings.Sum(r => r.Value) / e.Ratings.Count())
                    .Take(15)
                    .To<HomeIndexEstateViewModel>()
                    .ToList();

                appliances = this.appliances
                    .GetAll()
                    .OrderByDescending(a => a.Ratings.Count() == 0 ? 0 : a.Ratings.Sum(r => r.Value) / a.Ratings.Count())
                    .Take(15)
                    .To<HomeIndexApplianceViewModel>()
                    .ToList();

                ViewBag.Estates = estates;
                ViewBag.Appliances = appliances;

                this.HttpContext.Cache["Home estates"] = estates;
                this.HttpContext.Cache["Home appliances"] = appliances;
            }
                        
            return this.View(ViewBag);
        }
예제 #2
0
 public PropertyController(ApplicationDbContext context, IEstateService estateService,
                           IMapper mapper)
 {
     this.context       = context;
     this.estateService = estateService;
     this.mapper        = mapper;
 }
 public AdminController(ApplicationDbContext context,
                        IContactService contactService, IEstateService estateService)
 {
     this.context        = context;
     this.contactService = contactService;
     this.estateService  = estateService;
 }
예제 #4
0
 public EstateReviewsController(IReviewService reviewService, IEstateService estateService, IMapper mapper)
 {
     _reviewService = reviewService;
     _estateService = estateService;
     _mapper        = mapper;
 }
예제 #5
0
 public HomeController(IEstateService _estateService)
 {
     _EstateService = _estateService ?? throw new System.ArgumentNullException(nameof(_estateService));
 }
예제 #6
0
 public EstatesController(IEstateService estateService, IMapper mapper)
 {
     _estateService = estateService;
     _mapper        = mapper;
 }
 public EstatesController(ApplicationDbContext context, IEstateService estateService)
 {
     _context       = context;
     _estateService = estateService;
 }
예제 #8
0
 public EstatesController(KashanehContext context, IEstateService estateService, IUserService userService)
 {
     _context       = context;
     _estateService = estateService;
     _userService   = userService;
 }
예제 #9
0
 public HomeController(IEstateService estateService)
 {
     _estateService = estateService;
 }
예제 #10
0
 public HomeController(IEstateService estates, IApplianceService appliances)
 {
     this.estates = estates;
     this.appliances = appliances;
 }
예제 #11
0
 public EstateApiController(IEstateService estateService, IUserService userService)
 {
     this._estateService = estateService;
     this._userService   = userService;
     userId = Microsoft.AspNet.Identity.IdentityExtensions.GetUserId(RequestContext.Principal.Identity);
 }
예제 #12
0
 public EstateApiRestController(IEstateService estateService)
 {
     m_estateService = estateService;
 }