public static void DeleteOneUserProfile(int userProfileID) { var profile = new UserProfileRepository().GetById(userProfileID); // Delete all associated Messages var mRep = new MessageRepository(); var messages = mRep.All().Where(m => m.UserID == profile.UserID).ToList(); foreach (var m in messages) mRep.Delete(mRep.GetById(m.MessageID)); mRep.SaveChanges(); // Delete all associated Images var iRep = new ImageRepository(); var images = iRep.All().Where(i => i.UserID == profile.UserID).ToList(); foreach (var i in images) iRep.Delete(i.ImageID); iRep.SaveChanges(); // Delete all associated UserFriends var ufRep = new UserFriendRepository(); var userFriends = ufRep.All().Where(u => u.UserID == profile.UserID).ToList(); foreach (var u in userFriends) ufRep.Delete(u.UserFriendID); ufRep.SaveChanges(); var upRep = new UserProfileRepository(); upRep.Delete(upRep.GetById(profile.UserID)); upRep.SaveChanges(); // Finally delete user from Membership Membership.DeleteUser(Membership.GetUser(profile.aspUserID).UserName, true); }
public async Task<bool> Register(UserProfile userprofile) { try { var userProfileRepo = new UserProfileRepository(); await userProfileRepo.CreateSync(userprofile); var userId = userprofile.Id.ToString(); if (!string.IsNullOrEmpty(userId)) { var code = userId.Substring(userId.Length - 6, 6); var badge = new Badge { User = userprofile.Username, Code = code, IsAddressVerified = false, IsDriversLicenseVerified = false, IsPhoneVerified = false, IsVehicleVerified = false }; var badgeRepo = new BadgeRepository(); await badgeRepo.CreateSync(badge); return true; } return false; } catch(Exception ex) { return false; } }
public void UpdateJoinRoomTime(DateTime dateTime) { var profileRep = new UserProfileRepository(); UserProfile up = profileRep.GetById(UserID); up.JoinRoomTime = dateTime; profileRep.SaveChanges(); }
public void UpdateRoomID(int roomID) { var profileRep = new UserProfileRepository(); UserProfile up = profileRep.GetById(UserID); up.RoomID = roomID; up.JoinRoomTime = DateTime.Now.ToUniversalTime(); profileRep.SaveChanges(); }
public ActionResult UpdateAccount(int userid, string name, string email, string phone) { var mgr = new UserProfileRepository(); string onlyNumericPhone = Regex.Replace(phone, @"[^0-9]", ""); mgr.UpdateAccount(userid, name, email, onlyNumericPhone); TempData["success"] = "Your account was updated successfully!"; return(RedirectToAction("Index")); }
public void Filter(string nameFilter) { var repository = new UserProfileRepository(_dbContext, _cache.Object, _logger.Object); var pagedItems = repository.Filter(1, 20, new OrderBySelector <UserProfile, string>(OrderByType.Ascending, u => u.FirstName), f => f.FirstName.Contains(nameFilter) || f.LastName.Contains(nameFilter)); Assert.NotEmpty(pagedItems.Items); Assert.True(pagedItems.Items.TrueForAll(f => f.FirstName.Contains(nameFilter) || f.LastName.Contains(nameFilter))); }
public async Task <IdResult> ChangeInvitationState(Contact invitorUserProfile) { if (invitorUserProfile == null) { return(new IdResult() { IsOk = false, ErrorMessage = "No user info" }); } var dbUser = DbUser; using (UserContactRepository _userContactRepository = new UserContactRepository(Context, dbUser, null)) using (UserProfileRepository _userProfileRepository = new UserProfileRepository(Context, dbUser, null)) { var invitorUserProfileFromDb = _userProfileRepository.GetById(invitorUserProfile.Id); if (invitorUserProfile.Id != Guid.Empty && invitorUserProfileFromDb != null) { var userContactDB = _userContactRepository.GetByContactUserId(invitorUserProfileFromDb.Id, dbUser); if (userContactDB != null) { userContactDB.State = invitorUserProfile.State; userContactDB.StateDate = DateTime.Now; var senderUser = _userProfileRepository.GetById(userContactDB.MainUserId); if (invitorUserProfile.State == (byte)InvitationStates.Accepted) { _userContactRepository.Create(new UserContact() { ContactName = senderUser.FullName, ContactUserId = senderUser.Id, MainUserId = dbUser, State = (int)InvitationStates.Accepted, StateDate = DateTime.Now }); Utilities.AddNotification(dbUser, userContactDB.MainUserId, dbUser, (int)NotificationTypes.InvitationToContactsConfirmed, string.Format("You invitaion is accepted")); } Context.SaveChanges(); return(new IdResult() { IsOk = true, Id = userContactDB.Id, }); } } } return(new IdResult() { IsOk = false, ErrorMessage = "Error" }); //var user = JsonConvert.DeserializeObject<UserRegister>(userData); }
public async Task setUserOffline_SetOffline_UserSetOffline(int userId) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo, validationService); PublicUserProfileManager publicUserProfileManager = new PublicUserProfileManager(publicUserProfileService); PublicUserProfileModel model = new PublicUserProfileModel(); model.UserId = userId; try { await publicUserProfileManager.CeatePublicUserProfileAsync(model); await publicUserProfileManager.SetUserOnlineAsync(userId); await publicUserProfileManager.SetUserOfflineAsync(userId); IEnumerable <PublicUserProfileModel> models = await publicUserProfileRepo.GetAllPublicProfiles(); if (models == null) { Assert.IsTrue(false); } if (models.Count() == 0) { Assert.IsTrue(false); } foreach (var profile in models) { if (profile.Status == "Offline") { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } } catch { Assert.IsTrue(false); } }
// Sort through Rooms to find next one public static int NextRoomID() { // Find vacant Rooms. If none, create one and add it to list List<int> roomIDs = new List<int>(); vacantRoomInit: var allRooms = new RoomRepository().All().ToList(); var vacantRoomsWithUsers = (from room in allRooms where Enumerable.Range(1, 4).Contains(UserProfileController.GetUserProfileCount(room.RoomID)) select new { RoomID = room.RoomID }).ToList(); var emptyRooms = (from room in allRooms where UserProfileController.GetUserProfileCount(room.RoomID) == 0 select new { RoomID = room.RoomID }).ToList(); if (vacantRoomsWithUsers.Count == 0 && emptyRooms.Count > 0) { // All rooms with users are full but an empty one exists, return empty room return emptyRooms.First().RoomID; } else if (vacantRoomsWithUsers.Count == 0 && emptyRooms.Count == 0) { // Create new Room, re-populate vacantRoomIDs or obtain new RoomID another way var roomRep = new RoomRepository(); Room newRoom = new Room { Name = "Public Room" }; roomRep.Create(newRoom); roomRep.SaveChanges(); goto vacantRoomInit; } profileInit: // Change this to reflect online users only at deployment var allProfiles = new UserProfileRepository().All().ToList(); var profiles = (from p in allProfiles.Where(p => Membership.GetUser(p.aspUserID).IsOnline) where vacantRoomsWithUsers.Select(r => r.RoomID).Contains(p.RoomID) && !VisitedRooms.Select(r => r.RoomID).Contains(p.RoomID) select p).ToList(); if (profiles.Count == 0) { VisitedRooms.Clear(); goto profileInit; } // Obtain room with earliest JoinRoomTime var resultRoom = (from p in profiles group p by p.RoomID into results orderby results.Max(x => x.JoinRoomTime) select new { RoomID = results.Key }).First(); VisitedRooms.Add(new RoomRepository().GetById(resultRoom.RoomID)); return resultRoom.RoomID; }
public UnitOfWork(ApplicationDbContext context) { _context = context; ApplianceRepository = new ApplianceRepository(_context); JobOfferRepository = new JobOfferRepository(_context); PostRepository = new PostRepository(_context); UserProfileRepository = new UserProfileRepository(_context); UserSkillRepository = new UserSkillRepository(_context); SkillRepository = new SkillRepository(_context); }
public void Delete(int id) { var repository = new UserProfileRepository(_dbContext, _cache.Object, _logger.Object); repository.Delete(id); var testedItem = _dbContext.UserProfiles.Find(id); Assert.Null(testedItem); }
public ActionResult UpdateMethodNotification(int userid, string radio) { var mgr = new UserProfileRepository(); User u = mgr.UpdateMethodNotification(userid, radio); TempData["success"] = "Your notification method was updated successfully!"; SMSManager manager = new SMSManager(); return(RedirectToAction("Index")); }
public void shouldShowLoggedInUsersIdealWeight() { var userProfileRepository = new UserProfileRepository(); var userProfile = userProfileRepository.GetByUserId(UserId); var userIdealWeight = userProfile.IdealWeight; var idealWeightString = userIdealWeight.ToString("N1") + "kg"; Assert.That(Browser.ContainsText(idealWeightString), "Page did not contain: " + idealWeightString); }
private async void DeleteMethod() { var result = await this.DisplayAlert("Warning", "Sure to Delete the User ?", "Yes", "No"); if (result) { CommonAppData.Commonuserprofile.IsActive = false; var result1 = new UserProfileRepository().AddItem(CommonAppData.Commonuserprofile); } }
public void GetUserProfiles() { // arrange var userProfileRepository = new UserProfileRepository(Context); // act var allUsers = userProfileRepository.GetAll(); //assert Assert.Equal(2, allUsers.Count()); }
public async Task GetUserProfileByEmail() { // arrange var userProfileRepository = new UserProfileRepository(Context); // act var user = await userProfileRepository.GetUserProfileAsync("*****@*****.**"); //assert Assert.Equal("Test", user.Model.Name); }
public UserInformation LoginUser(string username, string password) { var userInformation = new UserInformation { UserInfo = new User() }; try { var user = GetUser(username); if (user == null || user.UserId < 1) { _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Login Failed! Reason: Incorrect Username or Password"; userInformation.Status = _status; return(userInformation); } string msg; if (!ValidateUser(user, password, out msg)) { _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = string.IsNullOrEmpty(msg) ? "Unable to login" : msg; userInformation.Status = _status; return(userInformation); } var userProfile = new UserProfileRepository().GetUserProfile(user.UserProfileId); if (userProfile == null) { _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Login Failed! Unrecognized Staff Information"; userInformation.Status = _status; return(userInformation); } if (string.IsNullOrEmpty(userProfile.ProfileNumber)) { _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Login Failed! Unrecognized Staff Information"; userInformation.Status = _status; return(userInformation); } user.UserProfile = userProfile; _status.IsSuccessful = true; userInformation.Status = _status; userInformation.UserInfo = user; return(userInformation); } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); _status.Message.FriendlyMessage = "Login Failed! Reason: " + ex.Message; _status.Message.TechnicalMessage = "Error: " + ex.Message; userInformation.Status = _status; return(userInformation); } }
/// <summary> /// Constructor /// </summary> public WorkflowServiceHelper( TimeTrackerOptions timeTrackerOptions, GraphAppUserService graphUserService, GraphAppSharePointService graphSharePointService, UserProfileRepository userProfileRepository) { _timeTrackerOptions = timeTrackerOptions ?? throw new ArgumentNullException(nameof(timeTrackerOptions)); _graphUserService = graphUserService ?? throw new ArgumentNullException(nameof(graphUserService)); _graphSharePointService = graphSharePointService ?? throw new ArgumentNullException(nameof(graphSharePointService)); _userProfileRepository = userProfileRepository ?? throw new ArgumentNullException(nameof(userProfileRepository)); }
public async Task UpdateProfileDescriptionAsync_UpdateValue_ValueUpdated(int userId, string description) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo, validationService); PublicUserProfileModel model = new PublicUserProfileModel(); model.UserId = userId; try { await publicUserProfileService.CeatePublicUserProfileAsync(model); model.Description = description; await publicUserProfileService.UpdateProfileDescriptionAsync(model); IEnumerable <PublicUserProfileModel> models = await publicUserProfileRepo.GetAllPublicProfiles(); if (models == null) { Assert.IsTrue(false); } if (models.Count() == 0) { Assert.IsTrue(false); } foreach (var profile in models) { if (profile.Description == description) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } } catch { Assert.IsTrue(false); } }
public AccountController( ApplicationUserManager userManager, ApplicationSignInManager signInManager, IAuthenticationManager authenticationManager, UserProfileRepository userProfileRepository) { _userManager = userManager; _signInManager = signInManager; _authenticationManager = authenticationManager; _userProfileRepository = userProfileRepository; }
public MssqlWorker(DbContext context) { if(context == null) throw new ArgumentNullException(nameof(context)); _context = context; ItemRepository = new TodoItemRepository(context); ListRepository = new TodoListRepository(context); ProfileRepository = new UserProfileRepository(context); UserRepository = new UserRepository(context); LogRepository = new LoggerRepository(context); }
public void VerifyGetUsersByCategory() { var repository = new UserProfileRepository(cosmosDbConnectionString); IList <UserProfile> profiles = repository.GetUsersByCategory("app-service"); IList <UserProfile> noProfiles = repository.GetUsersByCategory("jhghjg"); Assert.NotNull(profiles); Assert.NotEmpty(profiles); Assert.Empty(noProfiles); }
public async Task editUserProfilePicture_EditPhoto_PhotoSuccessfullyEdited(int userId, string photo) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo, validationService); PublicUserProfileManager publicUserProfileManager = new PublicUserProfileManager(publicUserProfileService); PublicUserProfileModel model = new PublicUserProfileModel(); try { model.UserId = userId; await publicUserProfileManager.CeatePublicUserProfileAsync(model); model.Photo = photo; await publicUserProfileManager.EditUserProfilePictureAsync(model); IEnumerable <PublicUserProfileModel> models = await publicUserProfileRepo.GetAllPublicProfiles(); if (models == null) { Assert.IsTrue(false); } if (models.Count() == 0) { Assert.IsTrue(false); } foreach (var profile in models) { if (profile.Photo == photo) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } } catch { Assert.IsTrue(false); } }
public async Task <ActionResult> LoginFacebook(LoginViewModel model) { if (!ModelState.IsValid) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { success = false, responseText = "Invalid parameters" }, JsonRequestBehavior.AllowGet)); } var user = UserManager.Users.Where(n => n.UserName == model.UserName); if (!user.Any()) { var createResult = await UserManager.CreateAsync(new ApplicationUser { UserName = model.UserName }, "socialMedia"); var userProfileRepo = new UserProfileRepository(); userProfileRepo.CreateSync(new Data.Model.UserProfile { Username = model.UserName, Password = "******", Email = model.Email, isFacebookUser = false, DateRegistered = DateTime.UtcNow }); UserManager.Create(new ApplicationUser { UserName = model.UserName }, model.Password); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.UserName, "socialMedia", model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: return(Json(new { success = true, responseText = "Added." }, JsonRequestBehavior.AllowGet)); break; // return RedirectToLocal(returnUrl); ////case SignInStatus.LockedOut: // return View("Lockout"); //case SignInStatus.RequiresVerification: // return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }); //case SignInStatus.Failure: //default: // ModelState.AddModelError("", "Invalid login attempt."); // return View(model); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { success = false, responseText = "Invalid parameters" }, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult UpdateProfile(UserProfileModel model) { try { if (model != null) { UserProfile profile = new UserProfile { UserId = model.UserId, FirstName = model.FirstName, LastName = model.LastName, Gender = model.Gender, Email = model.Email, Phone = model.Phone, Mobile = model.Mobile, Street = model.Street, City = model.City, Image = model.Image, Location = model.Location, LocationLatitude = model.LocationLatitude, LocationLongitude = model.LocationLongitude, ContactMethod = model.ContactMethod, BankId = model.BankId, BankBranch = model.BankBranch, AccountName = model.AccountName, AccountNo = model.AccountNo, NotificationFrequencyMinutes = model.NotificationFrequencyMinutes }; using (AppDBContext context = new AppDBContext()) { var repo = new UserProfileRepository(context); var existing = repo.GetByUserId(profile.UserId); if (existing == null) { repo.Add(profile); } else { repo.Update(profile); } } } return(Ok()); } catch (Exception ex) { Logger.Log(typeof(UserController), ex.Message + ex.StackTrace, LogType.ERROR); return(InternalServerError()); } }
public ViewResult Index(int id) { UserProfileRepository userprofileRepository = new UserProfileRepository(); var userProfile = userprofileRepository.GetUserProfileByAccountID(id); if (userProfile == null) { //redirect error return(View("Http404")); } return(View("Index", userProfile)); }
public async Task DeleteUserProfileByAccountId_UserProfileExists_ReturnsNull(int accountId) { // Arrange IUserProfileRepository userProfile = new UserProfileRepository(new SQLServerGateway(), new ConnectionStringData()); // Act await userProfile.DeleteUserProfileByAccountId(accountId); var retrievedAccount = await userProfile.GetUserProfileByAccountId(accountId); // Assert Assert.IsNull(retrievedAccount); }
public async Task GetUserProfileById(int id, string expectedSurname) { // Arrange IUserProfileRepository userProfile = new UserProfileRepository(new SQLServerGateway(), new ConnectionStringData()); // Act var userProfileModel = await userProfile.GetUserProfileById(id); var actualSurname = userProfileModel.Surname; // Assert Assert.IsTrue(actualSurname == expectedSurname); }
//[HttpGet] //public Task<HttpResponseMessage> GetProfileImage(string id) //{ // //var rootPath = ConfigurationManager.AppSettings["RootPathToFiles"]; // //var serverPath = Path.Combine(rootPath, id); // //var fileExtension = Path.GetExtension(id); // //CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); // //CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // //CloudBlobContainer container = blobClient.GetContainerReference(""); // //CloudBlockBlob blob = container.GetBlockBlobReference(""); // //using (var memStream = new MemoryStream()) // //{ // // blob.DownloadToStream(memStream); // // // return File(memStream.ToArray(), blob.Properties.ContentType); // //} // //// localFilePath = getFileFromID(id, out fileName, out fileSize); // //HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); // //response.Content = new StreamContent(new FileStream(serverPath, FileMode.Open, FileAccess.Read)); // //response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); // //response.Content.Headers.ContentDisposition.FileName = id; // //response.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeTypeMap.GetMimeType(fileExtension)); // //return response; //} //public FileResult DownloadBlob(string folderName, string fileName) //{ // // The code in this section goes here. // //return new FileContentResult() //} public Task <HttpResponseMessage> GetProfileImage(Guid userId) { using (UserProfileRepository userProfileRepository = new UserProfileRepository()) { var user = userProfileRepository.GetById(userId); if (user != null) { return(GetProfileImageByName(user.ProfileImageString)); } return(null); } }
public void Update(int id) { var updatedItem = _dbContext.UserProfiles.Find(id); updatedItem.LastName += " Jr."; var repository = new UserProfileRepository(_dbContext, _cache.Object, _logger.Object); repository.Update(updatedItem); var testedItem = _dbContext.UserProfiles.Find(id); Assert.Equal(updatedItem.LastName, testedItem.LastName); }
public static void CreateUserProfile(Guid aspUserID, DateTime joinRoomTime, int type, int roomID) { var profileRep = new UserProfileRepository(); UserProfile up = new UserProfile { aspUserID = aspUserID, JoinRoomTime = joinRoomTime.ToUniversalTime(), Type = type, RoomID = roomID }; profileRep.Create(up); profileRep.SaveChanges(); }
public MssqlWorker(DbContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } _context = context; ItemRepository = new TodoItemRepository(context); ListRepository = new TodoListRepository(context); ProfileRepository = new UserProfileRepository(context); UserRepository = new UserRepository(context); LogRepository = new LoggerRepository(context); }
public FileResult GetProfileImage(Guid userId) { using (MindCornersEntities context = new MindCornersEntities()) using (UserProfileRepository userProfileRepository = new UserProfileRepository()) { var user = userProfileRepository.GetById(userId); if (user != null) { return(GetProfileImageByName(user.ProfileImageString)); } return(null); } }
public ActionResult Index() { var mgr = new UserProfileRepository(); ProfileViewModel vm = new ProfileViewModel(); vm.User = mgr.GetUser(int.Parse(User.Identity.Name)); vm.Organizations = mgr.GetOrganization(int.Parse(User.Identity.Name)); Contact c = mgr.GetContact(int.Parse(User.Identity.Name)); if (c != null) { vm.Contact = c; } return(View(vm)); }
public ActionResult UpdateNotification(int userid, string name, string phone, string email) { var mgr = new UserProfileRepository(); User u = mgr.UpdateNotification(userid, name, phone, email); TempData["success"] = "Your notification contact info was updated successfully!"; SMSManager manager = new SMSManager(); //if (radio == "2" || radio == "3") //{ // string message = "This notification is to confirm that you have updated your notification settings to enable SMS reminders."; // manager.Notification(u.PhoneNumber, message); //} return(RedirectToAction("Index")); }
public async Task CreateReportAsync_CreateReport_ReportCreated(int userId1, int userId2, string report) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IFriendRequestListRepo friendRequestListRepo = new FriendRequestListRepo(dataGateway, connectionString); IFriendBlockListRepo friendBlockListRepo = new FriendBlockListRepo(dataGateway, connectionString); IFriendListRepo friendListRepo = new FriendListRepo(dataGateway, connectionString); IUserReportsRepo userReportsRepo = new UserReportsRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IUserInteractionService userInteractionService = new UserInteractionService(friendBlockListRepo, friendListRepo, friendRequestListRepo, userReportsRepo, validationService); UserReportsModel model = new UserReportsModel(); model.ReportedId = userId1; model.ReportingId = userId2; model.Report = report; try { await userInteractionService.CreateReportAsync(model); IEnumerable <UserReportsModel> userReports = await userReportsRepo.GetAllReports(); if (userReports == null) { Assert.IsTrue(false); } if (userReports.Count() == 0) { Assert.IsTrue(false); } foreach (var userReport in userReports) { if (userReport.Report == report && userReport.ReportedId == userId1 && userReport.ReportingId == userId2) { Assert.IsTrue(true); } } } catch { Assert.IsTrue(false); } }
public ActionResult Edit(UserInfoModel model) { if (ModelState.IsValid) { UserProfileRepository userprofileRepository = new UserProfileRepository(); userprofileRepository.SaveUserProfile(model); return(RedirectToAction("Index", model.AccountID)); } else { ModelState.AddModelError("", "User profile saving was unsuccessful. Please correct the errors and try again."); } return(View("Edit", model)); }
private void button1_Click(object sender, EventArgs e) { UserProfile user = new UserProfile(); user.Name = Name.Text; user.Surname = Surname.Text; user.Phone = Phone.Text; user.Area1 = FirstArea.Text; user.Area2 = SecondArea.Text; user.Area3 = ThirdArea.Text; Community value = (Community)CommunityCmbx.SelectedItem; user.CommunityID = value.ID; UserProfileRepository repo = new UserProfileRepository(); repo.WriteUser(user); }
public void UserRepository_AddItem_IsNotNullWhenGet() { var dbData = new DalUserProfile { Id = 100, Email = "mail1", Name = "name1", Password = "******" }; var dbSetMock = new Mock<DbSet<OrmUserProfile>>(); var dbContextMock = new Mock<EntityModelContext>(); dbContextMock.Setup(x => x.Set<OrmUserProfile>()).Returns(dbSetMock.Object); var repo = new UserProfileRepository(dbContextMock.Object); repo.Add(dbData); Assert.IsNotNull(repo.Get(100)); }
public static void CreateTestProfiles(int quantity) { UserProfile newProfile = new UserProfile(); Random rnd = new Random(); for (int i = 1; i <= quantity; i++) { string username = ""; username = "******" + rnd.Next(10000,100000).ToString(); Membership.CreateUser(username, "tester!", "*****@*****.**"); newProfile.aspUserID = (Guid)Membership.GetUser(username).ProviderUserKey; newProfile.JoinRoomTime = DateTime.Now.ToUniversalTime(); newProfile.RoomID = RoomController.NextRoomID(); newProfile.Type = 0; var profileRep = new UserProfileRepository(); profileRep.Create(newProfile); profileRep.SaveChanges(); } }
public async Task<ActionResult> Badges() { var badgeRepository = new BadgeRepository(); var badge = await badgeRepository.GetBadge(User.Identity.Name); if (badge == null) { var userProfileRepo = new UserProfileRepository(); var user = await userProfileRepo.GetUserProfile(User.Identity.Name); var code = user.Id.ToString().Substring(user.Id.ToString().Length - 6, 6); badge = new Badge { User = User.Identity.Name, Code = code, IsAddressVerified = false, IsDriversLicenseVerified = false, IsPhoneVerified = false, IsVehicleVerified = false }; var badgeRepo = new BadgeRepository(); await badgeRepo.CreateSync(badge); } return View(badge); }
public async Task<ActionResult> LoginFacebook(LoginViewModel model) { if (!ModelState.IsValid) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(new { success = false, responseText = "Invalid parameters" }, JsonRequestBehavior.AllowGet); } var user = UserManager.Users.Where(n => n.UserName == model.UserName); if (!user.Any()) { var createResult = await UserManager.CreateAsync(new ApplicationUser { UserName = model.UserName }, "socialMedia"); var userProfileRepo = new UserProfileRepository(); userProfileRepo.CreateSync(new Data.Model.UserProfile { Username = model.UserName, Password = "******", Email = model.Email, isFacebookUser = false, DateRegistered = DateTime.UtcNow }); UserManager.Create(new ApplicationUser { UserName = model.UserName }, model.Password); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.UserName, "socialMedia", model.RememberMe, shouldLockout: false); switch (result) { case SignInStatus.Success: return Json(new { success = true, responseText = "Added." }, JsonRequestBehavior.AllowGet); break; // return RedirectToLocal(returnUrl); ////case SignInStatus.LockedOut: // return View("Lockout"); //case SignInStatus.RequiresVerification: // return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }); //case SignInStatus.Failure: //default: // ModelState.AddModelError("", "Invalid login attempt."); // return View(model); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(new { success = false, responseText = "Invalid parameters" }, JsonRequestBehavior.AllowGet); }
public static List<UserProfile> GetUserProfiles(int roomID) { var profiles = new UserProfileRepository().All().Where(p => p.RoomID == roomID).ToList(); profiles = profiles.Where(p => Membership.GetUser(p.aspUserID).IsOnline).ToList(); return profiles; }
public static UserProfile GetByProviderKey(Guid providerKey) { var profile = new UserProfileRepository().All().Where(p => p.aspUserID == providerKey).FirstOrDefault(); return profile; }
public UnitOfWork() { _userProfileRepository = new UserProfileRepository(_context); }
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager ) { UserManager = userManager; SignInManager = signInManager; userProfileRepository = new UserProfileRepository(new ApplicationDbContext()); }
public UsersController() { UserRepository = new UserRepository(); UserProfileRepository = new UserProfileRepository(); }
public AccountController() { userProfileRepository = new UserProfileRepository(new ApplicationDbContext()); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; Guid providerKey = (Guid)Membership.GetUser().ProviderUserKey; int roomID = RoomController.NextRoomID(); // Check to see if user is new var profiles = new UserProfileRepository().All(); if (!profiles.Select(x => x.aspUserID).Contains(providerKey)) { // UserProfile not found, create new UserProfileController.CreateUserProfile(providerKey, DateTime.Now.ToUniversalTime(), 0, roomID); CurrentUser cUser = CurrentUser.Instance; cUser.ResetCurrentUser(); cUser.RoomID = roomID; cUser.UpdateRoomID(roomID); SendWelcomeMessage(roomID); UpdateMessages(); } else { // UserProfile exists, update profile CurrentUser cUser = CurrentUser.Instance; cUser.ResetCurrentUser(); cUser.RoomID = roomID; cUser.UpdateRoomID(roomID); SendWelcomeMessage(roomID); UpdateMessages(); } MessageInput.Focus(); }
public AdminController() { authContext = new ApplicationDbContext(); userProfileRepository = new UserProfileRepository(new ApplicationDbContext()); }
public static int GetUserProfileCount(int roomID) { var results = new UserProfileRepository().All().Where(p => p.RoomID == roomID).ToList(); results = results.Where(p => (Membership.GetUser(p.aspUserID).IsOnline)).ToList(); return results.Count; }
private IUserProfileRepository GetRepositoryWithEnrolledUnitOfWork() { IUserProfileRepository repository = new UserProfileRepository(WorkUnit); return repository; }
public BUserProfile() { userProfileRepository = new UserProfileRepository(); }
public static UserProfile GetUserProfile(Guid aspUserID) { var profile = new UserProfileRepository().All().Where(p => p.aspUserID == aspUserID).FirstOrDefault(); return profile; }
public UserProfile GetUserProfile() { var profile = new UserProfileRepository().GetById(UserID); return profile; }