public bool Save(FlagSetting entity)
        {
            bool isSuccess = false;

            if (string.IsNullOrEmpty(entity.Id))
            {
                _repository.Insert <FlagSetting>(entity);

                isSuccess = !string.IsNullOrEmpty(entity.Id) ? true : false;

                if (isSuccess)
                {
                    _redisCache.SetValue(entity.Name, entity.FlagValue);
                }

                return(isSuccess);
            }
            else
            {
                isSuccess = _repository.Update <FlagSetting>(entity);

                if (isSuccess)
                {
                    _redisCache.SetValue(entity.Name, entity.FlagValue);
                }
            }

            return(isSuccess);
        }
Example #2
0
        public void SetMasterData()
        {
            //insert these flags before hand for now.
            List <FlagSetting> lstFlagSetting = new List <FlagSetting>()
            {
                new FlagSetting {
                    Name = "bUseElasticSearchEngine", Description = "enable product search on ElasticSearch engine", FlagValue = "false", IsPermanent = false
                },
                new FlagSetting {
                    Name = "bShowLoadTime", Description = "Show load timings. This is used for identifying the bottle necks", FlagValue = "true", IsPermanent = true
                },
            };

            _cRepository.Insert <FlagSetting>(lstFlagSetting);

            List <ProgrammingRating> lstProgrammingRating = new List <ProgrammingRating>()
            {
                new ProgrammingRating {
                    Name = "Expert", Code = "EX"
                },
                new ProgrammingRating {
                    Name = "Good", Code = "GD"
                },
                new ProgrammingRating {
                    Name = "Average", Code = "AVG"
                },
                new ProgrammingRating {
                    Name = "Beginner", Code = "B"
                },
                new ProgrammingRating {
                    Name = "Hopeless", Code = "HL"
                },
            };

            _bRepository.Insert <ProgrammingRating>(lstProgrammingRating);

            List <Gender> lstGender = new List <Gender>()
            {
                new Gender {
                    Name = "Male", Code = "M"
                },
                new Gender {
                    Name = "Female", Code = "F"
                },
            };

            _bRepository.Insert <Gender>(lstGender);

            List <Skill> lstSkill = new List <Skill>()
            {
                new Skill {
                    Name = "Ruby On Rails", Code = "RR"
                },
                new Skill {
                    Name = "Core Java", Code = "J"
                },
                new Skill {
                    Name = "Java EE", Code = "J"
                },
                new Skill {
                    Name = "Scala"
                },
                new Skill {
                    Name = "Play Framework"
                },
                new Skill {
                    Name = "Python"
                },
                new Skill {
                    Name = "ASP.Net MVC"
                },
            };

            _bRepository.Insert <Skill>(lstSkill);

            List <ClientType> lstClientType = new List <ClientType>()
            {
                new ClientType {
                    Name = "Information Technology-1"
                },
                new ClientType {
                    Name = "Information Technology-2"
                },
                new ClientType {
                    Name = "Information Technology-3"
                },
                new ClientType {
                    Name = "Information Technology-4"
                },
                new ClientType {
                    Name = "Energy Sector-1"
                },
                new ClientType {
                    Name = "Energy Sector-2"
                },
                new ClientType {
                    Name = "Energy Sector-3"
                },
            };

            _bRepository.Insert <ClientType>(lstClientType);

            List <Author> lstAuthor = new List <Author>()
            {
                new Author {
                    Name = "Paulo Coelho"
                },
                new Author {
                    Name = "Amit Kumar"
                },
                new Author {
                    Name = "David Schwartz"
                },
                new Author {
                    Name = "Max Payne"
                },
                new Author {
                    Name = "Michael Hartl"
                },
            };

            _pcRepository.Insert <Author>(lstAuthor);

            List <BookCategory> lstBookCategory = new List <BookCategory>()
            {
                new BookCategory {
                    Name = "Python"
                },
                new BookCategory {
                    Name = "Java"
                },
                new BookCategory {
                    Name = "Inspiration, Motivation"
                },
                new BookCategory {
                    Name = "Fiction"
                },
                new BookCategory {
                    Name = "Ruby On Rails"
                },
            };

            _pcRepository.Insert <BookCategory>(lstBookCategory);

            //Create a text index on Book collection, this required for free text searching actually.
            var collection = _pcRepository.DbContext.GetCollection <Book>("Book");

            if (!collection.IndexExistsByName("book_text"))
            {
                collection.CreateIndex(IndexKeys.Text("nm", "au.nm", "ct.nm"), IndexOptions.SetName("book_text").SetWeight("nm", 4).SetWeight("au.nm", 3));
            }
        }