static void Main(string[] args) { List <Person> list = new List <Person>(); Console.Write("Enter the number of payers: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Tag player #{i} data:"); Console.Write("Individual or company (i/c)? "); char word = char.Parse(Console.ReadLine()); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Anual income: "); double anualIncome = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); if (word == 'i') { Console.Write("Health expenditures: "); double healthExpenditure = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Person physicalPerson = new PhysicalPerson(name, anualIncome, healthExpenditure); list.Add(physicalPerson); } else if (word == 'c') { Console.Write("Number of employees: "); int numberOfEmployees = int.Parse(Console.ReadLine()); Person juridicPerson = new JuridicPerson(name, anualIncome, numberOfEmployees); list.Add(juridicPerson); } } Console.WriteLine(); Console.WriteLine("TAXES PAID:"); double sum = 0.0; foreach (Person obj in list) { Console.WriteLine(obj.ToString()); sum += obj.TaxesPaid(); } Console.WriteLine(); Console.WriteLine("TOTAL TAXES: " + "$ " + sum.ToString("F2", CultureInfo.InvariantCulture)); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { var user = new IdentityUser { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { try { var typeUser = new JuridicPerson { UserId = user.Id, Name = JuridicPersonInputModel.Name, SecondName = JuridicPersonInputModel.SecondName, RucNumber = JuridicPersonInputModel.RucNumber, Pasaport = JuridicPersonInputModel.Pasaport, // CardNumber = JuridicPersonInputModel.CardNumber, Direction = JuridicPersonInputModel.Direction, PhoneNumber = JuridicPersonInputModel.PhoneNumber, BirthDate = JuridicPersonInputModel.BirthDate }; //By default a saving account will be created var savingAccount = new SavingAccount { // Id = user.Id, CreationDate = DateTime.Now.ToString(), FreezeStartDate = null, FreezeEndDate = null, CurrencyType = "US Dolar", //By default Freezed = false, Amount = 0, AmountGained = 0, NaturalPersonId = null, JuridicPersonId = user.Id }; var result2 = await _dbContext.JuridicPersons.AddAsync(typeUser); var result3 = await _dbContext.SavingAccounts.AddAsync(savingAccount); await _dbContext.SaveChangesAsync(); } catch (System.Exception) { await _userManager.DeleteAsync(user); //In any error, the Identity user //will be deleted, because one o his tables //didn't created correctly } _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); if (_userManager.Options.SignIn.RequireConfirmedAccount) { return(RedirectToPage("RegisterConfirmation", new { email = Input.Email })); } else { await _signInManager.SignInAsync(user, isPersistent : false); 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()); }