public Client() { var userRepos = new UserRepos(); var produto = new Product(); userRepos.Add(new User()); }
// GET: /user/{username} /// <summary> /// Default Action to view user repo details /// </summary> /// <param name="username"></param> /// <param name="page">pagination params</param> /// <param name="per_page">pagination params</param> /// <param name="gridPage">internal parameter to handle pagination in the page</param> /// <returns></returns> public async Task <ActionResult> Index(string username, int page = 1, int per_page = 30, int gridPage = 1) { if (string.IsNullOrEmpty(username)) { // Username is not passed return(View("Error", new HandleErrorInfo(new Exception("Please try with valid route. like /user/{username}"), "User", "Index"))); } try { IPagedList <UserRepo> model = null; // Fetches all user repos by username userAvailableRepos = await GitHubManager.GetUserGitHubRepo(username, page, per_page); if (userAvailableRepos == null || userAvailableRepos.Repos == null) { return(View("Error", new HandleErrorInfo(new Exception("Internal Error"), "User", "Index"))); } // Pagination logic model = userAvailableRepos.Repos.ToPagedList(gridPage, 10); ViewBag.Page = page; ViewBag.PerPage = per_page; return(View("Index", model)); } catch (Exception) { return(View("Error", new HandleErrorInfo(new Exception("Internal Error"), "User", "Index"))); } }
public IActionResult SignUp(User user) { UserRepos repository = new UserRepos(_connectionString); repository.AddUser(user); return(Redirect("/user/logIn")); }
public async Task AddTestUsers_AreNotEqual() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: "UserDatabase") .Options; using (var context = new AppDbContext(options)) { context.ct_user.Add(new User { Id = 1, Email = "*****@*****.**", Name = "jeremey", Password = "******" }); context.SaveChanges(); } using (var context = new AppDbContext(options)) { UserRepos userrepos = new UserRepos(context); User user = new User(); User getuser; user.Id = 2; user.Email = "*****@*****.**"; user.Name = "jeremey2"; user.Password = "******"; await userrepos.Add(user); getuser = await userrepos.GetAsync(1); Assert.AreNotEqual(user, getuser); } }
public void adminIsAdmin() { /////// UserRepos usr = new UserRepos(db); var users = usr.GetALL(); foreach (var item in users) { if (item.User_name == "admin") { Name = "admin"; //UsrId = item.User_id; } } ///////////////// RoleRepos rol = new RoleRepos(db); var roles = rol.GetALL(); foreach (var x in roles) { if (x.Role_name == "admin") { //RoleId = x.Role_id; role = "admin"; } } ///////////////// Assert.True(Name == role); }
public async Task DeleteTest_Users_ReturnNull() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: "UserDatabase") .Options; using (var context = new AppDbContext(options)) { context.ct_user.Add(new User { Id = 1, Email = "*****@*****.**", Name = "jeremey", Password = "******" }); context.SaveChanges(); } using (var context = new AppDbContext(options)) { UserRepos userrepos = new UserRepos(context); await userrepos.Delete(1); User getuser; getuser = await userrepos.GetAsync(1); Assert.IsNull(getuser); } }
// DELETE: api/User/5 public void Delete(int id) { UserStory e = new UserStory(); e.userstoryid = id; UserRepos.Operation_delete_id(id); }
public UserController(UserRepos userService, IConfiguration configuration, UserManager <IdentityUser> usermanager, IMailService mailService) { _userService = userService; _mailService = mailService; _configuration = configuration; _usermanager = usermanager; }
public async Task Test_Index_InternalError() { var userController = new UserController(_mockGitHubManager.Object); // Get the test data UserRepos repos = new UserRepos(); UserRepo repo = new UserRepo { name = "test" }; repos.Repos = new System.Collections.Generic.List <UserRepo>(); repos.Repos.Add(repo); var taskCompletion = new TaskCompletionSource <UserRepos>(); taskCompletion.SetResult(null); _mockGitHubManager.Setup(m => m.GetUserGitHubRepo(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns(taskCompletion.Task); var result = await userController.Index("SomePath"); // Validate the result Assert.NotNull(result); Assert.IsType <ViewResult>(result); var viewResult = result as ViewResult; if (viewResult != null) { Assert.Equal(viewResult.ViewName, "Error"); } }
public AddSToGroup_Screen() { InitializeComponent(); repos = new UserRepos(); showStudents(); showGroups(); }
public Student_Screen(User user) { InitializeComponent(); this.user = user; repos = new UserRepos(); studentGrade(); }
public User Get() { var userRepo = new UserRepos(); var name = RequestContext.Principal.Identity.Name; var userName = name.Substring(name.LastIndexOf(@"\") + 1); return(userRepo.GetUser(userName)); }
public IActionResult Index() { UserRepos userRepos = new UserRepos(); userRepos.user = GithubProfile.GetInfo(); userRepos.starredRepos = GithubProfile.GetStarredRepos(); return(View(userRepos)); }
public CreateController(NoteRepos noteRepos, UserRepos userRepos, AppDbContext auc, ServiceRepos servicesRepos, SpecRepos specRepos) { this.noteRepos = noteRepos; this.userRepos = userRepos; this.specRepos = specRepos; this.servicesRepos = servicesRepos; this.auc = auc; }
public UnitOfWork(ToDoListContext context) { _context = context; ToDoTasks = new ToDoTaskRepos(_context); Users = new UserRepos(_context); JointUsers = new JointUserRepos(_context); Comments = new CommentRepos(_context); AttachedFiles = new AttachedFileRepos(_context); DbLogs = new DbLogRepos(_context); }
public IActionResult SignUp(Registration sr) { if (ModelState.IsValid) { UserRepos.AddUser(sr); return(View("Welcome", sr)); } else { return(View()); } }
public void UserReposTest() { Start(); //Иницилизация UserRepos userRepos = new UserRepos(new LibraryContext(connectionOption)); Assert.IsNotNull(userRepos); //Бронировка int Id = userRepos.AllBooks.ElementAt(1).Id; userRepos.BusyBook(Id, 1); Assert.IsTrue(userRepos.GetBook(Id).IsBusy); Assert.AreEqual(userRepos.GetBook(Id).IdAccount, 1); userRepos.TakeOff(Id); Assert.IsFalse(userRepos.GetBook(Id).IsBusy); //Поиск книг Assert.AreEqual(userRepos.FindBookByAuthor("author1").First().Title, "title1"); Assert.AreEqual(userRepos.FindBookByPublisher("publisher2").First().Title, "title2"); Assert.AreEqual(userRepos.FindBookByGenre("genre1").First().Title, "title1"); Assert.IsNotNull(userRepos.FindBookByGenre("12")); //Комментарии Comment comment1 = new Comment() { IdBook = 1, TextComment = "comment1" }; Comment comment2 = new Comment() { IdBook = 1, TextComment = "comment2" }; userRepos.MakeComment(comment1); userRepos.MakeComment(comment2); Assert.AreEqual(userRepos.ReadComments(1).ElementAt(0).TextComment, "comment1"); Assert.IsNotNull(userRepos.ReadComments(20)); //Книги и аккаунты Assert.AreEqual(userRepos.AllBooks.Count(), 2); Assert.IsNotNull(userRepos.GetBook(10000)); Assert.AreEqual(userRepos.GetBook(Id).Title, "title2"); Assert.AreEqual(userRepos.MyAccount("11", "name1").Email, "email1"); Assert.IsNotNull(userRepos.MyAccount("", "")); End(); }
public void FailedLogin() { UserRepos ur = new UserRepos(db); string uName = "Basma"; //invaid password int password = 12345; User u = new User(); u.User_name = uName; u.Password = password; bool login = ur.SuccedLogin(u); Assert.False(login); }
public void SuccededLogin() { UserRepos ur = new UserRepos(db); //User u = new User(); string uName = "Basma"; int password = 123; User u = new User(); u.User_name = uName; u.Password = password; bool login = ur.SuccedLogin(u); //bool x = true; Assert.True(login); }
public IActionResult LogIn(string email, string password) { UserRepos repository = new UserRepos(_connectionString); string passwordFromDB = repository.GetPasswordForEmail(email); if (passwordFromDB == null) { return(Redirect("/user/logIn")); } 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 Lecturer_Screen(User user) { InitializeComponent(); this.user = user; repos = new UserRepos(); sRepos = new SubjectRepos(); subjectList = sRepos.LecturerSubjectList(user.ID); groupList = sRepos.LecturerGroup(user.ID); for (int i = 0; i < subjectList.Count; i++) { subjectBox.Items.Add(subjectList[i].Subjectname); aSubjectBox.Items.Add(subjectList[i].Subjectname); } for (int i = 0; i < groupList.Count; i++) { groupComboBox.Items.Add(groupList[i].GroupName); aGroupBox.Items.Add(groupList[i].GroupName); } showStudents(); }
public UserService(IConfiguration configuration) { repos = new UserRepos(configuration); }
// POST: api/User public void Post(UserStory value) { MainDBC db = new MainDBC(); UserRepos.Createuserstories(value); }
public AddLecturer_Screen() { InitializeComponent(); repos = new UserRepos(); }
public Login_Screen() { InitializeComponent(); repos = new UserRepos(); }
public AddStudent_Screen() { InitializeComponent(); repos = new UserRepos(); }