public UserController(UserServices userServices, RoleServices roleServices, MessageServices messageServices, UsersFilter usersFilter) { this.roleServices = roleServices; this.userServices = userServices; this.messageServices = messageServices; this.usersFilter = usersFilter; }
public NetworkServices() { MasterServer.ipAddress = ServerData.MasterServerIP; _localUserPath = Application.dataPath + "/userProfile.dat"; // Sets the Match Settings ServerData.serverInfo.settings = MatchSettings.Instance; _userService = new UserServices(_localUserPath); RefreshHostList(); }
public TrainingTeamMembersServices(UserServices userServices, IQualificationToFaCourseRepository qualificationToFaCourseRepository, IQualificationRepository qualificationRepository, IUserRepository userRepository, IFACourseRepository faCourseRepository, ICoachRepository coachRepository) { _userServices = userServices; _qualificationToFaCourseRepository = qualificationToFaCourseRepository; _qualificationRepository = qualificationRepository; _userRepository = userRepository; _faCourseRepository = faCourseRepository; _coachRepository = coachRepository; }
public void DeleteUserNonExistentTest() { UserRepositoryMock.Setup(repository => repository.FindUserById(It.IsAny<int>())).Returns(() => null); UserRepositoryMock.Setup(repository => repository.DeleteUser(It.IsAny<int>())); var userServices = new UserServices(DbContext, null, null); var result = userServices.DeleteUser(It.IsAny<int>()); UserRepositoryMock.Verify(repository => repository.DeleteUser(It.IsAny<int>()), Times.Never); Assert.IsFalse(result); }
public void GetAllUsersTest() { var list = new List<User> { new User(), new User() }; UserRepositoryMock.Setup(repository => repository.GetAllUsers()).Returns(() => list); var userServices = new UserServices(DbContext, MappingEngine, null); var result = userServices.GetAllUsers(); Assert.AreEqual(list.Count, result.Count()); }
public static bool logout() { if (!user.getUserName().Equals("guest") && UserServices.onlineUsers.Contains(user.getUserName())) { // DirAppend.AddToLogger("user " + user.getUserName() + " logout", Result.Log); // DirAppend.AddToLogger("user " + user.getUserName() + " logout", Result.Log); if (UserServices.logout(user.getUserName())) { aUser olduser = user; user = new Guest(); userName = user.getUserName(); return(true); } } // DirAppend.AddToLogger("There was a failed login attempt", Result.Warnning); return(false); }
public HttpResponseMessage UpdateLocation(LocalUser model) { if (model == null || string.IsNullOrEmpty(model.Id) || string.IsNullOrEmpty(model.LocTempo) || string.IsNullOrEmpty(model.LocationName)) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ApiResponseModel { Success = false, Message = "Data not mapped", Data = model })); } var latlng = model.LocTempo.Split('_'); if (latlng.Length != 2) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ApiResponseModel { Success = false, Message = "LocTempo is not in correct format .i.e. lat_lng", Data = model })); } try { var updatedUser = UserServices.UpdateLocInfo(model); return(Request.CreateResponse(HttpStatusCode.OK, new ApiResponseModel { Success = updatedUser != null, Message = updatedUser != null ? "Successfully User location updated": "User does not exist or error occurred", Data = model })); } catch (Exception excep) { var response = new ApiResponseModel { Data = null, Message = excep.InnerException.Message, Success = false }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, response)); } }
public ActionResult InsertSolution(SolutionModel model, HttpPostedFileBase upload) { CourseServices cs = new CourseServices(); UserServices us = new UserServices(); HttpCookie loggedStudent = Request.Cookies["LoggedUser"]; model.Student = us.GetStudent(loggedStudent.Values.Get("Login")); model.StudentId = model.Student.IdUcznia; model.FileName = upload.FileName; using (var reader = new System.IO.BinaryReader(upload.InputStream)) { model.Solution = reader.ReadBytes(upload.ContentLength); } cs.NewSolution(model); return(RedirectToAction("ManageCourses", "Student")); }
private void btnLogin_Click(object sender, EventArgs e) { //try //{ if (txtUsername.Text != "") { // int check=0; if (txtUsername.Text == "test") { Form1 form = new Form1(); userName = txtUsername.Text; form.Show(); Hide(); } else { UserServices userService = new UserServices(); var result = userService.Login(txtUsername.Text, txtPassword.Text); if (txtPassword.Text == result.Password && txtUsername.Text == result.Username) { Form1 form = new Form1(); userName = txtUsername.Text; form.Show(); Hide(); } else { MessageBox.Show("Invalid Username and Password"); } } } else { MessageBox.Show("Please Input Username", "Error"); } //} //catch (Exception error) //{ // MessageBox.Show(error.Message, "System Error"); //} }
public ShoppingBasket(BasketInRecipt shoppingBasketData) { this.products = new LinkedList <Product>(); ICollection <ProductData> productsInBasketData = shoppingBasketData.products; foreach (ProductData p_data in productsInBasketData) { this.products.Add(new Product(p_data)); } ThreadStart linkStore = new ThreadStart(() => this.store = Stores.searchStore(shoppingBasketData.recipt.store.storeName)); ThreadStart linkOwner = new ThreadStart(() => this.owner = UserServices.getUser(shoppingBasketData.recipt.user.userName)); // this.store = new Store(shoppingBasketData.recipt.store); // this.owner = new Member(shoppingBasketData.recipt.user); Build.addLink(linkStore); Build.addLink(linkOwner); }
public ActionResult StudentSolution(int TaskId) { CourseServices cs = new CourseServices(); UserServices us = new UserServices(); HttpCookie cookie = Request.Cookies.Get("LoggedUser"); cookie.Values.Get("Name"); cookie.Values.Get("Surname"); cookie.Values.Get("Login"); StudentModel student = new StudentModel(); student = us.GetStudent(cookie.Values.Get("Login")); SolutionModel solution = new SolutionModel(); solution = cs.GetSolution(TaskId, student); return(View(solution)); }
public async Task IsFindById_Called_Once() { var userManagerMock = new Mock <IUserManagerProvider>(); var tweetRepoMock = new Mock <ITweetRepository>(); var userService = new UserServices(tweetRepoMock.Object, userManagerMock.Object); var user = new ApplicationUser { Id = "1231412" }; userManagerMock.Setup(x => x.FindByIdAsync(It.IsAny <string>())).ReturnsAsync(user).Verifiable(); var userId = "1231412"; await userService.DeleteUserAsync(userId); userManagerMock.Verify(x => x.FindByIdAsync(userId), Times.Once); }
//Method that removes movie from favorites private void RemoveMovieFromFavorites(GridUpdateArgs gua) { string selectedMovieTitle = gua.ID; string userName = gua.UserName; IUser UserServices = new UserServices(); Guid UserID = UserServices.GetUserID(userName); bool check = UserServices.RemoveMovieFromFavoriteList(UserID, selectedMovieTitle); if (check) { Myview.Model.IsValidTransastion = true; } else { Myview.Model.IsValidTransastion = false; } }
public void FindUserById() { var data = SetupMockData(); UserSet.Setup(set => set.Provider).Returns(data.Provider); UserSet.Setup(set => set.Expression).Returns(data.Expression); UserSet.Setup(set => set.ElementType).Returns(data.ElementType); UserSet.Setup(set => set.GetEnumerator()).Returns(data.GetEnumerator()); ContextMock.Setup(c => c.Entity<User>()).Returns(UserSet.Object); var repository = new UserServices(ContextMock.Object, LoggingHelperMock.Object); var id = 1; var user = repository.FindUserById(id); Assert.IsNotNull(user); Assert.AreEqual(id, user.Id); }
public UserViewModel() { #region Instantiate public properties and service objects User = new UserInfo(); Users = new ObservableCollection <UserInfo>(); userService = new UserServices(); _IsAddEnabled = false; #endregion #region Configure Command Properties by passing private method references to it //GetProductsCommand = new Command(GetData); AddUserCommand = new Command(AddUser); NavigateCommand = new Command(Navigate); PassControlCommand = new Command(PassControl); CheckUserCommand = new Command(CheckUser); #endregion }
public async Task <IActionResult> DeleteConfirmed(int id) { // find the webRootPath string webRootPath = _hostingEnvironment.WebRootPath; // find the Product by it's ID UserServices userServices = await _colibriDbContext.UserServices.FindAsync(id); if (userServices == null) { return(NotFound()); } else { // find the Image File var uploads = Path.Combine(webRootPath, StaticDetails.ImageFolderService); // find the Extension var extension = Path.GetExtension(userServices.Image); // exists the File? if (System.IO.File.Exists(Path.Combine(uploads, userServices.Id + extension))) { // remove the File System.IO.File.Delete(Path.Combine(uploads, userServices.Id + extension)); } // remove the Entry from the DB _colibriDbContext.UserServices.Remove(userServices); // save the Changes asynchronously await _colibriDbContext.SaveChangesAsync(); // TODO // Publish the Created Advertisement's Product using (var bus = RabbitHutch.CreateBus("host=localhost")) { Console.WriteLine("Publishing messages with publish and subscribe."); Console.WriteLine(); bus.Publish(userServices, "removed_user_services_by_admin"); } // avoid Refreshing the POST Operation -> Redirect return(RedirectToAction(nameof(Index))); } }
public void UpdateUser_WhenValid_ShouldCommit() { var user = ModelTestHelper.CreateUser(-1, "CommitUser"); var service = new UserServices(); var userRepo = new UserRepository(); userRepo.SaveUser(user); Assert.IsFalse(userRepo.HasErrors); var oldNumber = user.PhoneNumber; user.PhoneNumber = "UpdatedNumber"; service.UpdateUser(user); var dbUser = service.GetUserInfo(user.Pseudo); Assert.IsNotNull(dbUser); Assert.AreEqual("UpdatedNumber", dbUser.PhoneNumber); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { UserServices userServices = GetUserServicesViaDIContainer(); // you'll need to figure out how to implement this string userId = filterContext.HttpContext.User.Identity.Name bool hasTicket = userServices.HasTicket(_ticketType, (int)userId); // again, you'll need to figure out the exact implementation if (!hasTicket) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Home" }, { "action", "NoPermission" } }) } else { base.OnActionExecuting(filterContext); } }
public async Task <ActionResult> Index(User user) { UserServices userServices = new UserServices(); if (!userServices.CheckUser(user)) { ViewBag.UserNotHave = true; return(View()); } else { ViewBag.login = user.login; await MethodWithDelayAsync(milliseconds); return(View("UserRoom")); } }
public void Register_WhenCalledWithInValid_UsernameAndPassword_ReturnsBadRequest(User UserTestData) { // Arrange var dbContext = DbContextMocker.WookieBooksImportersDbContext(); var userServices = new UserServices(GetAppSettings()); var usersController = new UsersController(dbContext, userServices); // Act var queryRes = usersController.Register(UserTestData).Result; var data = queryRes.Result as ObjectResult; dbContext.Dispose(); // Assert Assert.Equal(StatusCodes.Status400BadRequest, data.StatusCode); }
public IActionResult EditService(UserServices userService, int id) { var userServices = _userService.GetUserService(userService.ServiceId); userService.UserProfileId = userServices.UserProfileId; _userService.Update(userService); var service = new ServiceViewModel { ServiceDescription = userService.ServiceDescription, ServiceId = userService.ServiceId, UserId = userService.UserProfileId, ServiceName = userService.ServiceName }; return(View(service)); }
private void Login() { using (var userService = new UserServices()) { var securityToken = userService.Login(new UserLoginDto { Username = username, Password = password }); Assert.IsFalse(string.IsNullOrWhiteSpace(securityToken)); var user = userService.Read(securityToken); Assert.IsNotNull(user); Assert.IsTrue(user.Id > 0); } }
protected override void BindValueToPageControls() { //Chọn người yêu cầu là lãnh đạo đơn vị foreach (var user in UserServices.GetList(new[] { UserRole.LanhDaoDonVi })) { LanhDaoYeuCau.AddSelectItem(user.FullName, user.UserID.ToString(), user.DepartmentName?.ToUpper()); } //Chuyên viên theo dõi: tất cả cá nhân trong đơn vị foreach (var user in UserServices.GetList()) { ChuyenVienTheoDoi.AddSelectItem(user.FullName, user.UserID.ToString(), user.DepartmentName?.ToUpper() + "."); } //Đơn vị thực hiện ý kiến chỉ đạo DonViThucHien.BindData(DepartmentServices.GetList().ToList <object>(), "DepartmentID", "DepartmentName", "DepartmentGroupName"); }
public void TestGetCurrentUserNoToken() { ServerConfiguration configuration = new ServerConfiguration() { JwtSecretKey = "secret" }; UserServices userServices = new UserServices(DataProviderMock); UserResult res = null; Task.Run(async() => { res = await userServices.GetCurrentUser(null, configuration); }).Wait(); Assert.AreEqual(res.Result, BlueDogResult.BadToken); }
public async Task GetListOfUsersDTO() { var userName = "******"; var userPassword = "******"; var userName2 = "user2"; var userPassword2 = "user2"; var roleId = 1; var roleName = "user"; var userFactoryMock = new Mock <IUserFactory>(); var bannFactoryMock = new Mock <IBannFactory>(); var hasherMock = new Mock <IHasher>(); var options = TestUtilities.GetOptions(nameof(GetListOfUsersDTO)); var user = new User(userName, userPassword, roleId); var user2 = new User(userName2, userPassword2, roleId); var bann = new Bann(); var role = new Role(); using (var arrangeContext = new CocktailMagicianDb(options)) { user.Role = role; user.Bann = bann; user2.Role = role; user2.Bann = bann; role.Name = roleName; role.Id = roleId; arrangeContext.Roles.Add(role); arrangeContext.Users.Add(user); arrangeContext.Users.Add(user2); await arrangeContext.SaveChangesAsync(); } using (var assertContext = new CocktailMagicianDb(options)) { var sut = new UserServices(assertContext, userFactoryMock.Object, bannFactoryMock.Object, hasherMock.Object); var listTest = await sut.GetListOfUsersDTO(); Assert.IsTrue(listTest.Count() == 2); Assert.IsTrue(assertContext.Users.Count() == 2); } }
public HttpResponseMessage SaveTaskGridFilters([FromBody] UserPreference userPref) { try { userPref.preferenceType = "TaskFilter"; UserServices.UpdateUserPreference(userPref); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/SaveTaskGridFilters"); WebExceptionHelper.LogException(ex, null); return(null); } }
public void DeleteUserTest() { var user = new User { Id = 1 }; UserRepositoryMock.Setup(repository => repository.FindUserById(It.IsAny<int>())).Returns(() => user); UserRepositoryMock.Setup(repository => repository.DeleteUser(It.IsAny<int>())); var userServices = new UserServices(DbContext, null, null); var result = userServices.DeleteUser(It.IsAny<int>()); UserRepositoryMock.Verify(repository => repository.DeleteUser(It.IsAny<int>()), Times.Once); Assert.IsTrue(result); }
public ToDoServices(IToDoRepository toDoRepository, IUserRepository userRepository, UserServices userServices) { _toDoRepository = toDoRepository; _userRepository = userRepository; _userServices = userServices; }
public void UpdateUserNotificationsFalseTest() { var userDto = new UserDto { Id = 1, Gender = "Male", UserName = "******", }; var user = new User { Id = 1, Gender = Gender.Female, UserName = "******", }; UserRepositoryMock.Setup(repository => repository.FindUserById(It.IsAny<int>())).Returns(() => user); UserRepositoryMock.Setup(repository => repository.SaveOrUpdateUser(It.IsAny<User>())); var userServices = new UserServices(DbContext, MappingEngine, null); var result = userServices.UpdateUser(userDto); Assert.IsNotNull(result); Assert.IsNotNull(result.Dto); Assert.AreEqual(userDto.UserName, result.Dto.UserName); }
public void UpdateUserUsernameExistsTest() { var userDto = new UserDto { Id = 1, Gender = "Male", UserName = "******", }; var user = new User { Id = 1, Gender = Gender.Female, UserName = null, }; UserRepositoryMock.Setup(repository => repository.FindUserById(It.IsAny<int>())).Returns(() => user); UserRepositoryMock.Setup(repository => repository.FindUserByUserName(It.IsAny<string>())).Returns(() => new User()); UserRepositoryMock.Setup(repository => repository.SaveOrUpdateUser(It.IsAny<User>())); var userServices = new UserServices(DbContext, MappingEngine, null); var userServiceResult = userServices.UpdateUser(userDto); Assert.IsNotNull(userServiceResult); Assert.IsNotNull(userServiceResult.Dto); Assert.AreEqual(user.UserName, userServiceResult.Dto.UserName); Assert.AreEqual(UserServiceResultEnum.UsernameExists, userServiceResult.Result.Enum); }
public UserServicesTests() { _userServices = new UserServices("C:/TEMP/") { UserDataServices = A.Fake<IUserDataServices>() }; }
public void GetUserByIdNonExistentTest() { var user = new User { Id = 1 }; UserRepositoryMock.Setup(repository => repository.FindUserById(It.IsAny<int>())).Returns(() => null); var userServices = new UserServices(DbContext, MappingEngine, null); var result = userServices.GetUserById(It.IsAny<int>()); Assert.IsNull(result); }
private void ProcessNetflix(UserServices service) { if (service == null || service.Service.Type != ServiceTypeEnum.Netflix) return; var thread = new Thread(() => this.NetFlixWebBrowserManager(service)); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); this.Log("Acabou"); }
public SiteSettingsServices(IPasswordHistoryRepository passwordHistoryRepository, ITargetHistoryRepository targetHistoryRepository, UserServices userServices) { _passwordHistoryRepository = passwordHistoryRepository; _targetHistoryRepository = targetHistoryRepository; _userServices = userServices; }
private void NetFlixWebBrowserManager(UserServices service) { this.webBrowserNetFlix.DocumentCompleted += NetflixNavigationCompleted; #region login this.webBrowserNetFlix.Navigate("https://www.netflix.com/Login"); while (this.webBrowserNetFlix.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); Thread.Sleep(1000); } this.NetflixLogin(); #endregion #region profile this.webBrowserNetFlix.Navigate("https://www.netflix.com/YourAccount"); while (this.webBrowserNetFlix.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } this.NetflixProfileData(); #endregion }
public void GetUserByIdTest() { var user = new User { Id = 1 }; UserRepositoryMock.Setup(repository => repository.FindUserById(It.IsAny<int>())).Returns(() => user); var userServices = new UserServices(DbContext, MappingEngine, null); var result = userServices.GetUserById(It.IsAny<int>()); Assert.IsNotNull(result); Assert.AreEqual(user.Id, result.Id); }
public UsersFilter(UserServices userServices) { this.userServices = userServices; }