Example #1
0
        public WordsList GetRandomWord(string GameType)
        {
            int       recmaxcount = 100; // this need to assign from database.
            WordsList word        = new WordsList();
            Random    rand        = new Random();
            int       toSkip      = rand.Next(0, recmaxcount);

            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                context.Configuration.LazyLoadingEnabled   = false;
                context.Configuration.ProxyCreationEnabled = false;
                word = (from u in context.WordsLists
                        select u).OrderBy(x => x.WordString).Skip(toSkip).Take(1).FirstOrDefault();
            }

            //If the words list is empty then it will return null object.
            if (word == null)
            {
                return(null);
            }

            if (GameType == "J") // for getting Jambuled word.
            {
                word.WordStringChar = JumbleWord(word.WordString);
            }
            else if (GameType == "M") // it will return the word with Missing letters.
            {
                word.WordStringChar = MissingLetters(word.WordString);
            }

            word.WordString     = word.WordString.ToUpper();
            word.WordStringChar = word.WordStringChar.ToUpper();

            return(word);
        }
Example #2
0
        public string DeleteUser(string id)
        {
            string result = string.Empty;

            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                UserRegistration tempuser = (from u in context.UserRegistrations
                                             where u.UserId == id
                                             select u).FirstOrDefault();

                if (tempuser == null)
                {
                    context.Configuration.LazyLoadingEnabled   = false;
                    context.Configuration.ProxyCreationEnabled = false;

                    context.UserRegistrations.Remove(tempuser);
                    context.SaveChanges();
                    result = "User deleted successfully.";
                }
                else
                {
                    result = "User Not Found.";
                }
            }
            return(result);
        }
Example #3
0
        public string NewUserRegiration(UserRegistration user)
        {
            string result = string.Empty;

            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                UserRegistration tempuser = (from u in context.UserRegistrations
                                             where u.Email == user.Email
                                             select u).FirstOrDefault();

                if (tempuser == null)
                {
                    context.Configuration.LazyLoadingEnabled   = false;
                    context.Configuration.ProxyCreationEnabled = false;
                    user.UserId = System.Guid.NewGuid().ToString();
                    context.UserRegistrations.Add(user);
                    context.SaveChanges();
                    result = "User Registered Successfully.";
                }
                else
                {
                    result = "User alredy exist with Email ID.";
                }
            }
            return(result);
        }
Example #4
0
        public string UpdateUserProfile(UserRegistration user)
        {
            string result = string.Empty;

            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                UserRegistration tempuser = (from u in context.UserRegistrations
                                             where u.Email == user.Email
                                             select u).FirstOrDefault();

                if (tempuser == null)
                {
                    context.Configuration.LazyLoadingEnabled   = false;
                    context.Configuration.ProxyCreationEnabled = false;
                    context.UserRegistrations.Attach(user);
                    context.Entry(user).State = EntityState.Modified;
                    context.SaveChanges();
                    result = "User updated Successfully.";
                }
                else
                {
                    result = "User alredy exist with Email ID.";
                }
            }
            return(result);
        }
Example #5
0
        public UserRegistration UserRegistration(string Email, string Name, string Password)
        {
            string           result = string.Empty;
            UserRegistration user   = null;


            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                UserRegistration tempuser = (from u in context.UserRegistrations
                                             where u.Email == Email
                                             select u).FirstOrDefault();

                if (tempuser == null)
                {
                    user          = new UserRegistration();
                    user.UserId   = System.Guid.NewGuid().ToString();
                    user.Email    = Email;
                    user.FullName = Name;
                    user.Password = Password;
                    user.IsActive = true;

                    context.Configuration.LazyLoadingEnabled   = false;
                    context.Configuration.ProxyCreationEnabled = false;

                    context.UserRegistrations.Add(user);
                    context.SaveChanges();
                    result = "User Registered Successfully.";
                }
                else
                {
                    result = "User alredy exist with Email ID.";
                }
            }
            return(user);
        }
Example #6
0
        public List <GameType> GetGameTypes()
        {
            List <GameType> types = new List <GameType>();

            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                context.Configuration.LazyLoadingEnabled   = false;
                context.Configuration.ProxyCreationEnabled = false;
                types = (from u in context.GameTypes
                         select u).ToList();
            }

            if (types == null)
            {
                return(null);
            }
            return(types);
        }
Example #7
0
        public List <UserRegistration> GetUsers()
        {
            List <UserRegistration> user = new List <UserRegistration>();

            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                context.Configuration.LazyLoadingEnabled   = false;
                context.Configuration.ProxyCreationEnabled = false;
                user = (from u in context.UserRegistrations
                        select u).ToList();
            }

            if (user == null)
            {
                return(null);
            }

            return(user);
        }
Example #8
0
        public List <PastHistory> GetPasHistory(string userid)
        {
            List <PastHistory> history = new List <PastHistory>();

            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                context.Configuration.LazyLoadingEnabled   = false;
                context.Configuration.ProxyCreationEnabled = false;
                history = (from u in context.PastHistories
                           orderby u.Datetime descending
                           select u).ToList();
            }

            if (history == null)
            {
                return(null);
            }

            return(history);
        }
Example #9
0
        public UserRegistration GetUserProfile(string userid)
        {
            UserRegistration user = new UserRegistration();

            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                context.Configuration.LazyLoadingEnabled   = false;
                context.Configuration.ProxyCreationEnabled = false;
                user = (from u in context.UserRegistrations
                        where u.UserId == userid
                        select u).FirstOrDefault();
            }

            if (user == null)
            {
                return(null);
            }

            return(user);
        }
Example #10
0
        public UserRegistration UserLogin(string email, string password)
        {
            UserRegistration user = new UserRegistration();

            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                context.Configuration.LazyLoadingEnabled   = false;
                context.Configuration.ProxyCreationEnabled = false;
                user = (from u in context.UserRegistrations
                        where u.Email == email && u.Password == password
                        select u).FirstOrDefault();
            }

            if (user == null)
            {
                return(null);
            }

            return(user);
        }
Example #11
0
        public string InsertGameHistory(string userId, string origialWord, string displayString, string gameType)
        {
            string      result = "Fail";
            PastHistory game   = new PastHistory();

            game.GameId   = System.Guid.NewGuid().ToString();
            game.UserId   = userId;
            game.Datetime = System.DateTime.Now;

            game.ActualString  = origialWord;
            game.DisplayString = displayString;
            game.GameTypeId    = gameType;

            game.TempDateTime = System.DateTime.Today.ToShortDateString();

            if (origialWord.Trim().ToLower().Equals(displayString.Trim().ToLower()))
            {
                game.Score      = 10;
                game.GameStatus = "Success";
            }
            else
            {
                game.Score      = 0;
                game.GameStatus = "Fail";
            }

            //insert the record into the database
            using (SIMSGamesEntities context = new SIMSGamesEntities())
            {
                context.Configuration.LazyLoadingEnabled   = false;
                context.Configuration.ProxyCreationEnabled = false;
                context.PastHistories.Add(game);
                context.SaveChanges();
                result = "Success";
            }
            return(game.GameStatus);
        }