View on GitHub

ShopList

Craigslist Clone

ShopList

Objective

To build a Craigslist clone utilizing knowledge of front-end layouts, complex model structuring, image uploads, and pagination. ——

Features

    public class ChooseLocationViewModel
    {
        public int? SelectedLocId { get; set; }
        public IEnumerable<SelectListItem> Locs { get; set; }
    }
        private IEnumerable<SelectListItem> GetLocs()
        {
            var locs = db.Locs
                        .Select(x =>
                                new SelectListItem
                                {
                                    Value = x.Id.ToString(),
                                    Text = x.Locale
                                });
            return new SelectList(locs, "Value", "Text");
        }
        public ActionResult LocList()
        {
            var model = new ChooseLocationViewModel
            {
                Locs = GetLocs()
            };
            return View(model);
        }

——-

    public ActionResult Index(int loc_Id, int subCat_Id, string viewOrder, string view)
    {
        ...
        // view option ("thumb","list", etc) passed to frontend through viewbag
        ViewBag.View = view;
        
        var posts = db.Posts.Where(p => p.SubCat_Id == subCat_Id && p.Loc_Id == loc_Id);
        
        //order logic processed here 
        if (viewOrder == "high")
            {
                ViewBag.Posts = posts.ToList().OrderByDescending(p => p.Price);
            }
        else if...
    }

#####ShopList was built during Week 8 of The Iron Yard’s 12-Week immersive web development course