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); }
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); }
public bool SetPrediction(dom.Prediction prediction, string username) { prediction.CreationDate = DateTime.Now; if (ExtContext != null && IntContext == null) { UserHelper uh = new UserHelper(); var usr = uh.GetUserByUsername(username); prediction.User = usr; var e = ExtContext.Entry <dom.Prediction>(prediction).Entity; e.User = usr; ExtContext.Predictions.Attach(e).State = EntityState.Added; return(ExtContext.SaveChanges() > 0); } else { var uh = new UserHelper(new InMemoryDbContext()); var us = uh.GetUserByUsername(username); prediction.User = us; var e = IntContext.Entry <dom.Prediction>(prediction).Entity; e.User = us; IntContext.Predictions.Attach(e).State = EntityState.Added; return(IntContext.SaveChanges() > 0); } }
public bool SetAnonymousPrediction(dom.Prediction prediction) { return(SetPrediction(prediction, "anonymous")); }