public string AddSubCategory([FromBody] AddCategoryModel model)
        {
            IMongoDAL dal = new MongoDAL();

            dal.InsertCategorySubCategory(model.category, model.subcategory);
            return("OK");
        }
        public List <ListItem> GetCategories()
        {
            IMongoDAL dal = new MongoDAL();

            var result   = dal.GetCategorySubCategory();
            var response = new Dictionary <string, string>();

            response.Add("--select--", "--select--");
            foreach (BsonDocument item in result)
            {
                if (!response.Keys.Contains(item["Category"].ToString()))
                {
                    response.Add(item["Category"].ToString(), item["Category"].ToString());
                }
            }

            var listItemResponse = new List <ListItem>();

            foreach (var item in response.Keys)
            {
                listItemResponse.Add(new ListItem {
                    Id = item, Value = item
                });
            }

            return(listItemResponse);
        }
Example #3
0
        public ListItem Update([FromBody] Information model)
        {
            IMongoDAL dal = new MongoDAL();

            return(new ListItem {
                Id = "Like", Value = dal.Like(model.Id).ToString()
            });
        }
Example #4
0
        public void ConfigureServices(IServiceCollection services)
        {
            var settings = SettingsItem.Load();

            // Swap out the Class if DAL swap
            var dal = new MongoDAL(settings);

            dal.Initialize();

            services.AddSingleton <BaseDAL>(dal);

            services.AddGrpc();
        }
Example #5
0
        public void ConfigureServices(IServiceCollection services)
        {
            var settings = SettingsItem.Load();

            // Swap out the Class if DAL swap
            var dal = new MongoDAL(settings);

            dal.Initialize();

            services.AddSingleton <BaseDAL>(dal);

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddSingleton <PacketDataService>();
        }
Example #6
0
        public List <Information> GetAllRecords([FromUri] EditorViewModel model)
        {
            IMongoDAL dal    = new MongoDAL();
            var       result = dal.GetInformation(model.Country, model.State, model.City, model.Category, model.SubCategory);

            List <Information> response = new List <Information>();

            foreach (var item in result)
            {
                response.Add(new Information {
                    Id = item["_id"].ToString(), Descrption = item["Description"].ToString(), Likes = Convert.ToInt32(item["Likes"].ToString())
                });
            }

            return(response);
        }
        public Dictionary <string, string> GetCategories()
        {
            IMongoDAL dal = new MongoDAL();

            var result   = dal.GetCategorySubCategory();
            var response = new Dictionary <string, string>();

            response.Add("--select--", "--select--");
            foreach (BsonDocument item in result)
            {
                if (!response.Keys.Contains(item["Category"].ToString()))
                {
                    response.Add(item["Category"].ToString(), item["Category"].ToString());
                }
            }

            return(response);
        }
        public List <ListItem> GetSubCategories([FromUri] string category = "")
        {
            IMongoDAL dal = new MongoDAL();

            var result   = dal.GetSubCategory(category);
            var response = new List <ListItem>();

            response.Add(new ListItem {
                Id = "--select--", Value = "--select--"
            });
            foreach (BsonDocument item in result)
            {
                response.Add(new ListItem {
                    Id = item["SubCategory"].ToString(), Value = item["SubCategory"].ToString()
                });
            }

            return(response);
        }
        public List <Information> GetAllRecords([FromUri] CategoryModel model)
        {
            IMongoDAL dal    = new MongoDAL();
            var       result = dal.GetInformation(model.Country, model.State, model.City, model.Category, model.SubCategory);

            var response = new List <Information>();

            if (result.Any())
            {
                foreach (var item in result)
                {
                    var responseItem = new Information();
                    responseItem.Likes       = item["Likes"].ToString();
                    responseItem.Description = item["Description"].ToString();
                    responseItem.PostDate    = item["PostDate"].ToString();
                    responseItem.Id          = item["_id"].ToString();
                    response.Add(responseItem);
                }
            }


            return(response);
        }
Example #10
0
        public void Create([FromBody] EditorViewModel model)
        {
            IMongoDAL dal = new MongoDAL();

            dal.Insert(model.Country, model.State, model.City, model.Category, model.SubCategory, model.information[0].Likes, model.information[0].Descrption);
        }
 public void Test_Init()
 {
     connectionString = "mongodb://localhost:27017";
     client           = new MongoDAL(connectionString);
 }
Example #12
0
 public string GetAllCourses()
 {
     MongoDAL dal = new MongoDAL();
     List<BsonDocument> courses = dal.getAllCourses();
     return courses.ToJson();
 }
Example #13
0
        public void Update([FromBody] Information model)
        {
            IMongoDAL dal = new MongoDAL();

            dal.Update(model.Id, model.Likes);
        }