// GET: Properties/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var property = await _propertyManager.Get(id);

            if (property == null)
            {
                return(HttpNotFound());
            }
            return(View(property));
        }
Exemple #2
0
        // GET: Good
        public ActionResult ConcreteGood(int id)
        {
            var comments = commentManager.GetAllCommentsByGoodId(id).ToList();
            GoodViewModelDTO mainmodel = new GoodViewModelDTO();
            GoodDTO          good      = goodmanager.GetAndCheckUser(id, Convert.ToInt32(User.Identity.GetUserId()));

            mainmodel.Good = good;

            ListCompareGoodDTO compgoods = Session["ComparingGoods"] as ListCompareGoodDTO;

            try
            {
                mainmodel.IsComparing = compgoods.CompareGoods[good.Category_Id].Contains(id);
            }
            catch
            {
                mainmodel.IsComparing = false;
            }

            List <GoodDTO> alloffers     = new List <GoodDTO>();
            List <GoodDTO> similaroffers = new List <GoodDTO>();

            Dictionary <string, string> properties = new Dictionary <string, string>();

            foreach (var item in good.PropertyValues.DictStringProperties)
            {
                string propertyname = propertymanager.Get(item.Key).Name;
                properties.Add(propertyname, item.Value);
            }
            //similaroffers = elasticmanager.GetSimilar(good.Name.Split(' ')[1]).ToList();
            similaroffers = elasticmanager.GetSimilar(good.Name).ToList();
            alloffers     = elasticmanager.GetByName(good.Name).ToList();

            foreach (var simgood in similaroffers)
            {
                simgood.Category = categoryManager.Get(simgood.Category_Id);
                simgood.WebShop  = webShopManager.GetById(simgood.WebShop_Id);
            }

            decimal minprice = (decimal)(similaroffers.Select(c => c.Price).Min() ?? good.Price);
            decimal maxprice = (decimal)(similaroffers.Select(c => c.Price).Max() ?? good.Price);

            mainmodel.AllOffers     = alloffers;
            mainmodel.SimilarOffers = similaroffers;
            mainmodel.MinPrice      = minprice;
            mainmodel.MaxPrice      = maxprice;
            mainmodel.Properties    = properties;
            if (User.Identity.IsAuthenticated)
            {
                mainmodel.UserId = Convert.ToInt32(User.Identity.GetUserId());
            }
            else
            {
                mainmodel.UserId = null;
            }

            mainmodel.Comments = commentManager.CheckCommentsDependency(Convert.ToInt32(User.Identity.GetUserId()), id).ToList();

            foreach (var comment in mainmodel.Comments)
            {
                comment.User = userManager.GetById(comment.UserId);
            }

            return(View(mainmodel));
        }