public async Task <IActionResult> OnPostAsync(string returnUrl = null) { var phoneNumber = HttpContext.Session.GetString("MobileNumber"); if (phoneNumber == null) { return(RedirectToPage("/Index")); } HttpContext.Session.Clear(); returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { Lodger x = await _userManager.FindByEmailAsync(Input.Email); if (x == null) { goto code; } bool isConfirmed = await _userManager.IsEmailConfirmedAsync(x); if (isConfirmed) { ModelState.AddModelError(string.Empty, "Sorry! The email address is already registered."); return(Page()); } code: var user = new Lodger { UserName = Input.UserName, Email = Input.Email, PhoneNumber = phoneNumber, PhoneNumberConfirmed = true, City = "Singapore", Country = "Singapore", Biography = "This user has not added their biography.", DateJoined = DateTime.Now, Gender = "Male", IPAddress = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(), is3AuthEnabled = "False" }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"<div style=width: 70%; margin: 0 auto;'><p><img style='display: block; margin-left: auto; margin-right: auto;' src='https://image.ibb.co/dyXbEy/test.png' alt='Infinite Lodging' width='198' height='94' /></p><h3 style='text-align: center;'>For security reasons, please verify your email.</h3><p style='text-align: center;'><a href='{HtmlEncoder.Default.Encode(callbackUrl)}'><img src='https://image.ibb.co/fNSJjJ/send.png' alt='Confirm Email' width='344' height='43' /></a></p><p style='text-align: center;'> </p><span style='color: #808080; font-size: small;'><em>This message was sent to {Input.Email}. You are receiving this because you're a ∞Lodging member, or you've signed up to receive email from us. Manage your preferences or unsubscribe. </em></span></div>"); userAlertMessage = "Please verify your email address first before logging in!"; return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
private string getDuty(Lodger l, List <Duty> duties) { foreach (Duty d in duties) { if (d.DutyId == l.PresetDuty) { return(d.Description); } } return("none"); }
private string getKitchen(Lodger l) { if (l.IsKitchen == 0) { return("no"); } else { return("yes"); } }
public async Task <IActionResult> OnGetAsync(int?id) { Lodger = await _userManager.GetUserAsync(User); if (Lodger == null) { var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Anonymous User Tried To Edit Customer Support id:" + id + " Record"; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.PerformedBy = null; auditrecord.AuditRecordId = Guid.NewGuid().ToString(); auditrecord.IPAddress = HttpContext.Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(); _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); return(RedirectToPage("/Error/NiceTry")); } if (id == null) { return(NotFound()); } CustomerSupport = await _context.CustomerSupport.FirstOrDefaultAsync(m => m.CustomerSupport_ID == id); if (Lodger.Id != CustomerSupport.Lodger.Id) { var user = await _userManager.GetUserAsync(User); var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "User Tried To Edit Another User's Customer Support" + id + " Record"; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.PerformedBy = user; auditrecord.AuditRecordId = Guid.NewGuid().ToString(); auditrecord.IPAddress = HttpContext.Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(); _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); return(RedirectToPage("/Error/NiceTry")); } CustomerSupport = await _context.CustomerSupport.FirstOrDefaultAsync(m => m.CustomerSupport_ID == id); if (CustomerSupport == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGet() { if (HttpContext.User.Identity.IsAuthenticated) { Lodger LodgerUser = await _userManager.GetUserAsync(User); if (HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() != LodgerUser.IPAddress) { await _signInManager.SignOutAsync(); userAlertMessage = "New IP Address detected! To preventing spoofing attacks, you have been logged out! Please check your email to verify your identity!"; } return(Page()); } return(Page()); }
public async Task <IActionResult> OnPostRevertChangesAsync() { if (!(ModelState.IsValid)) { return(Page()); } AuditRecord usingAuditRecord = _context.AuditRecords.First(ar => (ar.AuditRecordId == auditRecordId)); if (usingAuditRecord == null) { ModelState.AddModelError("Error!", "Audit Record Not Found!"); return(Page()); } Lodger cu = _context.Users.First(u => (u.Id == usingAuditRecord.PerformedBy.Id)); if (!(cu is Lodger)) { ModelState.AddModelError("Error!", "User Not Found!"); return(Page()); } UserRevert rt = _context.UserReverts.First(ur => (ur.AuditRecord.AuditRecordId == usingAuditRecord.AuditRecordId)); if (rt == null) { ModelState.AddModelError("Error!", "Revert Backup not found!"); return(Page()); } cu.FullName = rt.FullName; cu.Gender = rt.Gender; cu.AlternateEmail = rt.AlternateEmail; cu.Country = rt.Country; cu.City = rt.City; cu.Occupation = rt.Occupation; cu.Address = rt.Address; cu.GovernmentID = rt.GovernmentID; cu.Status = rt.Status; cu.Biography = rt.Biography; cu.Hobbies = rt.Hobbies; cu.Email = rt.Email; cu.PasswordHash = rt.PasswordHash; cu.PhoneNumber = rt.PhoneNumber; cu.PhoneNumberConfirmed = rt.PhoneNumberConfirmed; cu.is3AuthEnabled = rt.is3AuthEnabled; await _context.SaveChangesAsync(); return(RedirectToPage()); }
public async Task <IActionResult> OnPostDeleteUserRoleAsync(string delusername, string delrolename) { //When the Delete this user from Role button is pressed if ((delusername == null) || (delrolename == null)) { return(RedirectToPage("Manage")); } Lodger user = _context.Users.Where(u => u.UserName.Equals(delusername, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); if (await _userManager.IsInRoleAsync(user, delrolename)) { await _userManager.RemoveFromRoleAsync(user, delrolename); TempData["message"] = "Role removed from this user successfully"; } return(RedirectToPage("Manage")); }
public async Task <IActionResult> OnGetAsync(string userId, string code, string newEmail = null) { IdentityResult result = null; if (userId == null || code == null) { return(RedirectToPage("/Index")); } var user = await _userManager.FindByIdAsync(userId); if (user == null) { return(NotFound($"Unable to load user with ID '{userId}'.")); } if (newEmail == null) { result = await _userManager.ConfirmEmailAsync(user, code); } else { result = await _userManager.ChangeEmailAsync(user, newEmail, code); } if (result.Succeeded) { Lodger User = await _userManager.FindByIdAsync(userId); string Email = await _userManager.GetEmailAsync(User); List <Lodger> Lodgers = _userManager.Users.Where(l => l.Email == Email).ToList <Lodger>(); foreach (Lodger l in Lodgers) { if (!(l.EmailConfirmed)) { await _userManager.DeleteAsync(l); } } } if (!result.Succeeded) { throw new InvalidOperationException($"Error confirming email for user with ID '{userId}':"); } return(Page()); }
private async Task LoadSharedKeyAndQrCodeUriAsync(Lodger user) { // Load the authenticator key & QR code URI to display on the form var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); if (string.IsNullOrEmpty(unformattedKey)) { await _userManager.ResetAuthenticatorKeyAsync(user); unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); } SharedKey = FormatKey(unformattedKey); var email = await _userManager.GetEmailAsync(user); AuthenticatorUri = GenerateQrCodeUri(email, unformattedKey); }
public async Task <IActionResult> OnPostAsync(string selectedusername, string selectedrolename) { //When the Assign button is pressed if ((selectedusername == null) || (selectedrolename == null)) { return(RedirectToPage("Manage")); } Lodger AppUser = _context.Users.SingleOrDefault(u => u.UserName == selectedusername); LodgerRole AppRole = await _roleManager.FindByNameAsync(selectedrolename); IdentityResult roleResult = await _userManager.AddToRoleAsync(AppUser, AppRole.Name); if (roleResult.Succeeded) { TempData["message"] = "Role added to this user successfully"; return(RedirectToPage("Manage")); } return(RedirectToPage("Manage")); }
public async Task <IActionResult> OnPostSubmitReportAsync() { LodgerUser = await _userManager.FindByNameAsync(Username); if (!(LodgerUser is Lodger)) { isValidProfile = false; return(Page()); } Lodger LoggedInUser = await _userManager.GetUserAsync(User); if (Username == LoggedInUser.UserName) { return(StatusCode(403)); } await ValidateAndInitializeAsync(); ModelState.Remove("ReviewInput"); if (!(ModelState.IsValid)) { return(Page()); } VirusReport vr = await ScanForVirus(ReportEvidence); if (vr.Positives > 0) { ModelState.AddModelError("ReportEvidenceFileFailedVirusCheck", "ReportEvidence failed virus scan!"); ModelState.AddModelError("ReportEvidenceFileReportLink", vr.ReportLink); return(Page()); } var filename = Guid.NewGuid().ToString() + Path.GetExtension(ReportEvidence.FileName); var file = Path.Combine(_environment.ContentRootPath, "wwwroot", "reports", filename); using (var fileStream = new FileStream(file, FileMode.Create)) { await ReportEvidence.CopyToAsync(fileStream); } HttpContext.Session.SetString("ReportedUserId", LodgerUser.Id); HttpContext.Session.SetString("Reason", Reason); HttpContext.Session.SetString("EvidenceFileName", filename); return(RedirectToPage("/Reports/SendReport")); }
public async Task <IActionResult> OnPostConfirmationAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); // Get the information about the user from the external login provider var info = await _signInManager.GetExternalLoginInfoAsync(); if (info == null) { ErrorMessage = "Error loading external login information during confirmation."; return(RedirectToPage("./Login", new { ReturnUrl = returnUrl })); } if (ModelState.IsValid) { var user = new Lodger { UserName = Input.UserName, Email = Input.Email }; var result = await _userManager.CreateAsync(user); if (result.Succeeded) { result = await _userManager.AddLoginAsync(user, info); if (result.Succeeded) { //await _signInManager.SignInAsync(user, isPersistent: false); _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider); userAlertMessage = "Please verify your email address first before logging in!"; return(LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } LoginProvider = info.LoginProvider; ReturnUrl = returnUrl; return(Page()); }
public async Task <IActionResult> OnPostAddReviewAsync() { LodgerUser = await _userManager.FindByNameAsync(Username); if (!(LodgerUser is Lodger)) { isValidProfile = false; return(Page()); } Lodger LoggedInUser = await _userManager.GetUserAsync(User); if (Username == LoggedInUser.UserName) { return(StatusCode(403)); } await ValidateAndInitializeAsync(); ModelState.Remove("Reason"); ModelState.Remove("ReportEvidence"); if (!(ModelState.IsValid)) { return(Page()); } UserReview newReview = new UserReview() { UserReviewId = Guid.NewGuid().ToString(), ReviewContent = ReviewInput, ReviewFor = LodgerUser, ReviewBy = LoggedInUser, ReviewTimeStamp = DateTime.Now }; _context.UserReview.Add(newReview); await _context.SaveChangesAsync(); return(RedirectToPage("/Profile/Index", new { Username = Username })); }
static void Main(string[] args) { List <Owner> owner = new List <Owner>(); List <Agency> agency = new List <Agency>(); List <Object1> object1 = new List <Object1>(); List <Lodger> lodger = new List <Lodger>(); FileStream file1 = new FileStream("C:\\Users\\79889\\source\\repos\\ConsoleApp3\\Files\\Object.txt", FileMode.Create); FileStream file2 = new FileStream("C:\\Users\\79889\\source\\repos\\ConsoleApp3\\Files\\Owner.txt", FileMode.Create); FileStream file3 = new FileStream("C:\\Users\\79889\\source\\repos\\ConsoleApp3\\Files\\Agency.txt", FileMode.Create); FileStream file4 = new FileStream("C:\\Users\\79889\\source\\repos\\ConsoleApp3\\Files\\Lodger.txt", FileMode.Create); file1.Close(); file2.Close(); file3.Close(); file4.Close(); Object1.InputObject1(ref object1, ref owner); Owner.InputOwner(ref owner, ref object1, ref agency); Agency.InputAgency(ref agency, ref owner); Lodger.InputLodger(ref agency, ref owner); Console.ReadKey(); }
public async Task <IActionResult> OnGetAsync(string userId, string code) { Lodger LodgerUser = await _userManager.FindByIdAsync(userId); if (!(LodgerUser is Lodger)) { return(StatusCode(403)); } if (LodgerUser.AdditionalVerificationSecret == code) { LodgerUser.RequireAdditionalVerification = false; LodgerUser.AdditionalVerificationSecret = ""; LodgerUser.IPAddress = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(); //await _signinManager.SignInAsync(LodgerUser, false, null); //cant do the above because there are still multiple checks after sign in //also prevents hacker from signing in if he/she has access to the email userAlertMessage = $"New IP Address: {LodgerUser.IPAddress} confirmed! We can't log you in now, due to security reasons."; await _context.SaveChangesAsync(); return(RedirectToPage("/Index")); } userAlertMessage = "Failed to verify identity!"; return(RedirectToPage("/Index")); }
private string getDuty(Lodger l, List<Duty> duties) { foreach (Duty d in duties) { if (d.DutyId == l.PresetDuty) return d.Description; } return "none"; }
private string getKitchen(Lodger l) { if (l.IsKitchen == 0) return "no"; else return "yes"; }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); ReturnUrl = returnUrl; if (ModelState.IsValid) { Lodger LodgerUser = await _userManager.FindByNameAsync(Input.UserName); if (!(LodgerUser is Lodger)) { ModelState.AddModelError(string.Empty, "Invalid username or password."); return(Page()); } if (LodgerUser.LockoutEnd != null) { ModelState.AddModelError(string.Empty, "Sorry! Account locked out!"); return(Page()); } if (LodgerUser.is3AuthEnabled == "True") { HttpContext.Session.SetString("Username", Input.UserName); HttpContext.Session.SetString("Password", Input.Password); HttpContext.Session.SetString("RememberMe", Input.RememberMe.ToString()); return(RedirectToPage("/3AuthVerification", new { area = "" })); } if (LodgerUser.RequireAdditionalVerification) { userAlertMessage = "Please log in to your registered email to verify your new IP Address"; } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true if (LodgerUser.IPAddress != Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString()) { LodgerUser.RequireAdditionalVerification = true; LodgerUser.AdditionalVerificationSecret = Guid.NewGuid().ToString(); var callbackUrl = Url.Page( "/VerifyIdentity/Index", pageHandler: null, values: new { userId = LodgerUser.Id, code = LodgerUser.AdditionalVerificationSecret }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(LodgerUser.Email, "Verify your Identity", $"<div style=width: 70%; margin: 0 auto;'><p><img style='display: block; margin-left: auto; margin-right: auto;' src='https://image.ibb.co/dyXbEy/test.png' alt='Infinite Lodging' width='198' height='94' /></p><h3 style='text-align: center;'>For security reasons, please verify your identity.</h3><p style='text-align: center;'><a href='{callbackUrl}'><img src='https://image.ibb.co/htz0EJ/airplane.png' alt='Verify your Identity' /></a></p><p style='text-align: center;'> </p><span style='color: #808080; font-size: small;'><em>This message was sent to {LodgerUser.Email}. You are receiving this because you're a ∞Lodging member, or you've signed up to receive email from us. Manage your preferences or unsubscribe. </em></span></div>" ); userAlertMessage = "We've detected that you are logging in from a new IP Address, confirm your identity using your registered email!"; await _context.SaveChangesAsync(); return(RedirectToPage("/Index")); } var result = await _signInManager.PasswordSignInAsync(Input.UserName, Input.Password, Input.RememberMe, lockoutOnFailure : false); if (result.Succeeded) { _logger.LogInformation("User logged in."); userAlertMessage = "You have successfully logged in."; return(LocalRedirect(returnUrl)); } if (result.RequiresTwoFactor) { return(RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe })); } if (result.IsLockedOut) { _logger.LogWarning("User account locked out."); return(RedirectToPage("./Lockout")); } else if (result.IsNotAllowed) { ModelState.AddModelError(string.Empty, "Please verify your email address first!"); } else { ModelState.AddModelError(string.Empty, "Invalid username or password."); return(Page()); } } // If we got this far, something failed, redisplay form return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (ModelState.IsValid) { Lodger toBeVerifiedAgainst = await _userManager.FindByNameAsync(HttpContext.Session.GetString("Username")); if (patternInput.Equals(toBeVerifiedAgainst.is3AuthPattern)) { string username = HttpContext.Session.GetString("Username"); string password = HttpContext.Session.GetString("Password"); bool rememberMe = HttpContext.Session.GetString("RememberMe") == "True" ? true : false; var result = await _signInManager.PasswordSignInAsync(username, password, rememberMe, lockoutOnFailure : true); if (result.Succeeded) { HttpContext.Session.Clear(); userAlertMessage = "You have successfully logged in."; return(RedirectToPage("/Index")); } else { HttpContext.Session.Clear(); if (result.RequiresTwoFactor) { return(RedirectToPage("/Account/LoginWith2fa", new { area = "Identity", ReturnUrl = "./Index", RememberMe = rememberMe })); } if (result.IsLockedOut) { return(RedirectToPage("/Account/Lockout", new { area = "Identity" })); } else if (result.IsNotAllowed) { userAlertMessage = "Please verify your email address first!"; return(RedirectToPage("/Index")); } else { ErrorMessage = "Invalid username or password."; return(Page()); } } } else { if (HttpContext.Session.GetInt32("Tries") == null) { HttpContext.Session.SetInt32("Tries", 1); } else { var currentTries = HttpContext.Session.GetInt32("Tries"); HttpContext.Session.SetInt32("Tries", currentTries.Value + 1); if (HttpContext.Session.GetInt32("Tries").Value == 4) { toBeVerifiedAgainst.LockoutEnabled = true; toBeVerifiedAgainst.LockoutEnd = DateTime.Now.AddDays(1); await _userManager.UpdateAsync(toBeVerifiedAgainst); HttpContext.Session.Clear(); return(RedirectToPage("/Account/Lockout", new { area = "Identity" })); } } } } return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Lodger LodgerUser = await _userManager.GetUserAsync(User); if (LodgerUser == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } UserRevert ur = new UserRevert() { UserRevertId = Guid.NewGuid().ToString(), FullName = LodgerUser.FullName, Gender = LodgerUser.Gender, AlternateEmail = LodgerUser.AlternateEmail, Country = LodgerUser.Country, City = LodgerUser.City, Occupation = LodgerUser.Occupation, Address = LodgerUser.Address, GovernmentID = LodgerUser.GovernmentID, Status = LodgerUser.Status, Biography = LodgerUser.Biography, Hobbies = LodgerUser.Hobbies, Email = LodgerUser.Email, PasswordHash = LodgerUser.PasswordHash, PhoneNumber = LodgerUser.PhoneNumber, PhoneNumberConfirmed = LodgerUser.PhoneNumberConfirmed, is3AuthEnabled = LodgerUser.is3AuthEnabled }; var email = await _userManager.GetEmailAsync(LodgerUser); if (Input.Email != email) { //var setEmailResult = await _userManager.SetEmailAsync(user, Input.Email); LodgerUser.EmailConfirmed = false; var userId = await _userManager.GetUserIdAsync(LodgerUser); var code = await _userManager.GenerateChangeEmailTokenAsync(LodgerUser, Input.Email); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = userId, code = code, newEmail = Input.Email }, protocol: Request.Scheme); await _emailSender.SendEmailAsync( Input.Email, "Confirm your email", $"<div style=width: 70%; margin: 0 auto;'><p><img style='display: block; margin-left: auto; margin-right: auto;' src='https://image.ibb.co/dyXbEy/test.png' alt='Infinite Lodging' width='198' height='94' /></p><h3 style='text-align: center;'>For security reasons, please verify your new email address.</h3><p style='text-align: center;'><a href='{HtmlEncoder.Default.Encode(callbackUrl)}'><img src='https://image.ibb.co/gEX9mo/Logo_Makr_0k_Wnu_O.png' alt='Confirm Email' width='344' height='43' /></a></p><p style='text-align: center;'> </p><span style='color: #808080; font-size: small;'><em>This message was sent to {Input.Email}. You are receiving this because you're a ∞Lodging member, or you've signed up to receive email from us. Manage your preferences or unsubscribe. </em></span></div>"); userAlertMessage = "Please verify your new email address before logging in!"; AuditRecord auditRecord = new AuditRecord(); auditRecord.AuditActionType = "Changed Email"; auditRecord.AuditRecordId = Guid.NewGuid().ToString(); auditRecord.DateTimeStamp = DateTime.Now; auditRecord.PerformedBy = LodgerUser; auditRecord.IPAddress = HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(); ur.AuditRecord = auditRecord; _context.UserReverts.Add(ur); await _context.SaveChangesAsync(); await _context.SaveChangesAsync(); await _signInManager.SignOutAsync(); return(RedirectToPage("/Index", new { area = "" })); //if (!setEmailResult.Succeeded) //{ // var userId = await _userManager.GetUserIdAsync(user); // throw new InvalidOperationException($"Unexpected error occurred setting email for user with ID '{userId}'."); //} } //var phoneNumber = await _userManager.GetPhoneNumberAsync(user); //if (Input.PhoneNumber != phoneNumber) //{ // var setPhoneResult = await _userManager.SetPhoneNumberAsync(user, Input.PhoneNumber); // if (!setPhoneResult.Succeeded) // { // var userId = await _userManager.GetUserIdAsync(user); // throw new InvalidOperationException($"Unexpected error occurred setting phone number for user with ID '{userId}'."); // } //} await _signInManager.RefreshSignInAsync(LodgerUser); StatusMessage = "Your profile has been updated"; return(RedirectToPage()); }
static void Main(string[] args) { List <Owner> owner = new List <Owner>(); List <Agency> agency = new List <Agency>(); List <Object1> object1 = new List <Object1>(); List <Lodger> lodger = new List <Lodger>(); Object1.InputObject1(ref object1); LoadManager loader1 = new LoadManager("object1.txt"); loader1.BeginRead(); while (loader1.IsLoading) { object1.Add(loader1.Read(new Object1.Loader()) as Object1); } loader1.EndRead(); LoadManager loader2 = new LoadManager("Owner.txt"); loader2.BeginRead(); while (loader2.IsLoading) { owner.Add(loader2.Read(new Owner.Loader()) as Owner); } loader2.EndRead(); FileStream file1 = new FileStream("object1.txt", FileMode.Create); FileStream file2 = new FileStream("Owner.txt", FileMode.Create); FileStream file3 = new FileStream("Agency.txt", FileMode.Create); FileStream file4 = new FileStream("Lodger.txt", FileMode.Create); file1.Close(); file2.Close(); file3.Close(); file1.Close(); SaveManager first = new SaveManager("object1.txt"); foreach (var x in object1) { first.WriteObject(x); } SaveManager ownerInFle = new SaveManager("Owner.txt"); foreach (var x in owner) { ownerInFle.WriteObject(x); } SaveManager agencyInFle = new SaveManager("Agency.txt"); foreach (var x in owner) { agencyInFle.WriteObject(x); } SaveManager ownelodgerInFle = new SaveManager("Lodger.txt"); foreach (var x in owner) { ownelodgerInFle.WriteObject(x); } Owner.InputOwner(ref owner); Agency.InputAgency(ref agency); Lodger.InputLodger(ref lodger); Console.ReadKey(); }