示例#1
0
        public PredictionHelperTests()
        {
            User = new dom.User()
            {
                Name     = "anon",
                Username = "******",
                Password = "******"
            };

            Pred = new dom.Prediction()
            {
                Ticker = "ryry"
            };

            sut = new dom.Prediction()
            {
                CompanyName = "ryry's chicken and waffles",
                Ticker      = "ryry",
            };

            PredictionHelper = new dat.PredictionHelper(new Data.InMemoryDbContext());
            UserHelper       = new dat.UserHelper(new Data.InMemoryDbContext());

            UserHelper.SetUser(User);
            PredictionHelper.SetPrediction(Pred, User.Username);
        }
示例#2
0
        public UserHelperTests()
        {
            ExistUser = new dom.User()
            {
                Name     = "anon",
                Username = "******",
                Password = "******"
            };

            sut = new dom.User()
            {
                Name     = "john",
                Username = "******",
                Password = "******"
            };

            pr = new dom.Prediction()
            {
                Ticker = "ryry"
            };

            UserHelper = new dat.UserHelper(new Data.InMemoryDbContext());
            ph         = new dat.PredictionHelper(new Data.InMemoryDbContext());

            UserHelper.SetUser(ExistUser);
            ph.SetPrediction(pr, ExistUser.Username);
        }
示例#3
0
        internal bool SignUp(string name, string username, string password)
        {
            var uh = new UserHelper();

            var usr = new dom.User()
            {
                Name     = name,
                Username = username,
                Password = password
            };

            return(uh.SetUser(usr));
        }
示例#4
0
        public bool SetUser(dom.User user)
        {
            var checkuser = GetUserByUsername(user.Username);

            if (checkuser != null && checkuser.Username == user.Username)
            {
                return(false);
            }
            else
            {
                user.CreationDate = DateTime.Now;
                if (ExtContext != null && IntContext == null)
                {
                    ExtContext.Users.Add(user);
                    return(ExtContext.SaveChanges() > 0);
                }
                else
                {
                    IntContext.Users.Add(user);
                    return(IntContext.SaveChanges() > 0);
                }
            }
        }