static void Main(string[] args) { ConsoleWriter writer = null; try //BugFix #2b { HttpClient httpClient = new HttpClient(); JokeRepository jokeRepository = new JokeRepository(httpClient); NameRepository nameRepository = new NameRepository(httpClient); writer = new ConsoleWriter(); IReader reader = new ConsoleReader(writer); UserQuestions userQuestions = new UserQuestions(reader, writer); UserInteractions userInteractions = new UserInteractions(writer, userQuestions); JokeService jokeService = new JokeService(); ProgramRunner programRunner = new ProgramRunner(userInteractions, jokeRepository, nameRepository, jokeService); programRunner.Run(); } catch (Exception) { if (writer != null) { writer.WriteLine("Something went terribly wrong."); writer.WriteLine("Are you sure you're connected to the internet?"); } } }
public List <Joke> GetJokes() { var repo = new JokeRepository(_connection); var jokes = JokesApi.GetJokes(); repo.AddJokes(jokes); return(jokes); }
public void InitializeRepositories() { var jokeRepository = new JokeRepository(); var userRepository = new UserRepository(); _container.RegisterInstanceAs(jokeRepository); _container.RegisterInstanceAs(userRepository); }
public IActionResult AddSignup(User user) { user.Password = BCrypt.Net.BCrypt.HashPassword(user.Password); JokeRepository repo = new JokeRepository(_connectionString); repo.AddUser(user); return(Redirect("/home/index")); }
public IActionResult Jokes() { JokeRepository repo = new JokeRepository(_connectionString); JokesViewModel vm = new JokesViewModel(); vm.Jokes = repo.GetAllJokes(); vm.CurrentUser = repo.GetUserByEmail(User.Identity.Name); return(View(vm)); }
public IActionResult Index(int?jokeId) { JokeRepository repo = new JokeRepository(_connectionString); IndexViewModel vm = new IndexViewModel(); vm.Joke = jokeId.HasValue ? repo.GetJokeByid(jokeId.Value) : repo.GetJoke(); vm.LikeCount = repo.GetLikeCount(vm.Joke.Id); vm.CurrentUser = repo.GetUserByEmail(User.Identity.Name); return(View(vm)); }
public ProgramRunner( UserInteractions userInteractions, JokeRepository jokeRepository, NameRepository nameRepository, JokeService jokeService) { this.userInteractions = userInteractions; this.jokeRepository = jokeRepository; this.nameRepository = nameRepository; this.jokeService = jokeService; }
public void AddJokeTest_correct() { string[] actualUser = { "admin", "admin" }; var result = _JokeSQL.AddJoke("ala ma kota", ref actualUser); Assert.IsTrue(result); var repo = new JokeRepository(_context); int id = repo.GetNum(); var obj = repo.GetByID(id); repo.Delete(obj); }
public Joke GetJoke() { var joke = JokeApi.GetJoke(); var repo2 = new UserRepository(_connectionString); var user = repo2.GetByEmail(User.Identity.Name); var repo = new JokeRepository(_connectionString); var wasliked = repo.UserLikedJoke(joke.Id, user.Id); if (!wasliked) { return(joke); } return(repo.GetJokeWithLikes(joke.Id)); }
public void LikeJoke(LikeJokeViewModel vm) { var repo = new JokeRepository(_connectionString); var repo2 = new UserRepository(_connectionString); var user = repo2.GetByEmail(User.Identity.Name); vm.Joke.UserId = user.Id; var wasLiked = repo.UserLikedJoke(vm.Joke.Id, user.Id); if (!wasLiked) { repo.LikeJoke(vm.Joke, user.Id, vm.Liked); return; } repo.ChangeLikeStatusForJoke(vm.Joke, user.Id, vm.Liked); return; }
public IActionResult AddLogIn(string email, string password) { JokeRepository repo = new JokeRepository(_connectionString); User user = repo.Verify(email, password); if (user == null) { return(Redirect("/home/index")); } var claims = new List <Claim> { new Claim("user", email) }; HttpContext.SignInAsync(new ClaimsPrincipal(new ClaimsIdentity(claims, "Cookies", "user", "role"))).Wait(); return(Redirect("/home/index")); }
public CategoryJokesController() { _repository = new JokeRepository(); }
public virtual void Initialize() { _sut = new JokeRepository(); }
public IEnumerable <Joke> GetAllJokes() { var repo = new JokeRepository(_connectionString); return(repo.GetJokes()); }
public HomeController(IConfiguration configuration) { _connectionString = configuration.GetConnectionString("ConStr"); _repo = new JokeRepository(_connectionString); _urepo = new UserRepository(_connectionString); }
public List <Joke> GetAllJokes() { var repo = new JokeRepository(_connection); return(repo.GetAllJokes()); }
public UserLikedJokes GetLike(int id) { var repo = new JokeRepository(_connection); return(repo.GetLike(id, User.Identity.Name)); }
public void UpdateLike(LikeJoke likeJoke) { var repo = new JokeRepository(_connection); repo.UpdateLike(likeJoke.Id, likeJoke.Liked, User.Identity.Name); }
public JokeSteps(UserContext user, JokeRepository jokeRepository) { _user = user; _jokeRepository = jokeRepository; }
public JokeController() { _repository = new JokeRepository(); }
public IActionResult AddLike(int jokeId, bool likes) { JokeRepository repo = new JokeRepository(_connectionString); return(Json(repo.AddLike(jokeId, repo.GetUserByEmail(User.Identity.Name).Id, likes))); }
public JokeService(DbConnection dbConn) { _jokeRepository = new JokeRepository(dbConn); }
public BaseViewModel() { JokeRepository = DependencyService.Get <JokeRepository>(); FavoriteService = DependencyService.Get <FavoriteService>(); }
public JokeSQL(ServerDatabaseContext context) { x = new JokeRepository(context); y = new UserRepository(context); }