Example #1
0
        //private ApplicationDbContext db = new ApplicationDbContext();

        // GET: Admin
        public ActionResult Index()
        {
            LayoutViewModel mymodel = new LayoutViewModel();

            mymodel.areas         = DbLayer.GetAllAreas();
            mymodel.categories    = DbLayer.GetAllCategories();
            mymodel.subcategories = DbLayer.GetAllSubCategories();
            mymodel.locales       = DbLayer.GetAllLocales();
            mymodel.posts         = DbLayer.GetAllPosts();
            mymodel.users         = DbLayer.getAllUsers();
            return(View(mymodel));
        }
Example #2
0
        //need to think how to do this for other permutations of (area,locale) and (cat,subcat)
        // GET: List Posts
        public ActionResult Index(string area_id, string category_id, string Place, string Type)
        {
            //handle errors and edgecases

            if (area_id == null || category_id == null || Place == null || Type == null)
            {
                return(HttpNotFound());
            }

            if (Place == "Area" && Type == "Category")
            {
                if (!DbLayer.CheckIfAreaExists(area_id) || !DbLayer.CheckIfCategoryExists(category_id))
                {
                    return(HttpNotFound());
                }

                return(View(DbLayer.GetAllPosts(category_id, area_id)));
            }

            else if (Place == "Area" && Type == "SubCategory")
            {
                if (!DbLayer.CheckIfAreaExists(area_id) || !DbLayer.CheckIfSubCategoryExists(category_id))
                {
                    return(HttpNotFound());
                }

                return(View(DbLayer.GetAllPosts(category_id, area_id, Place, Type)));
            }

            else if (Place == "Locale" && Type == "Category")
            {
                if (!DbLayer.CheckIfLocaleExists(area_id) || !DbLayer.CheckIfCategoryExists(category_id))
                {
                    return(HttpNotFound());
                }

                return(View(DbLayer.GetAllPosts(category_id, area_id, Place, Type)));
            }

            else if (Place == "Locale" && Type == "SubCategory")
            {
                if (!DbLayer.CheckIfLocaleExists(area_id) || !DbLayer.CheckIfSubCategoryExists(category_id))
                {
                    return(HttpNotFound());
                }

                return(View(DbLayer.GetAllPosts(category_id, area_id, Place, Type)));
            }

            return(HttpNotFound());
        }
Example #3
0
        // Testing only for user. Other combinations like getAllPost based on
        // 2. Area
        // 3. Locale
        // 4. Category
        // 5. Subcategory
        public void Test_getAllPosts()
        {
            List <String> listPosts = new List <String> {
                "14"
            };

            var           result    = DbLayer.GetAllPosts("323534");
            List <String> postNames = new List <String>();

            foreach (var item in result)
            {
                postNames.Add(item.postNumber.ToString());
            }

            CollectionAssert.AreEqual(listPosts, postNames);
        }