private void AddClaim() { Claim newCLaim = new Claim(); Console.WriteLine("What is the Claim ID?"); string inputAsString = Console.ReadLine(); newCLaim.ClaimID = int.Parse(inputAsString); Console.WriteLine("What is the claim type?\n" + "1. Car\n" + "2. Home\n" + "3. Theft"); string typeAsString = Console.ReadLine().ToLower(); switch (typeAsString) { case "1": case "car": newCLaim.Type = ClaimType.Car; break; case "2": case "home": newCLaim.Type = ClaimType.Home; break; case "3": case "theft": newCLaim.Type = ClaimType.Theft; break; } Console.WriteLine("What is the claim description?"); newCLaim.Description = Console.ReadLine(); Console.WriteLine("What is the claim amount?"); string claimAmount = Console.ReadLine(); newCLaim.Amount = decimal.Parse(claimAmount); Console.WriteLine("What is the date of the incident? mm/dd/yyyy"); string dateOfIncident = Console.ReadLine(); newCLaim.DateOfAccident = DateTime.Parse(dateOfIncident); Console.WriteLine("What is the date of the claim? mm/dd/yyyy"); string dateOfClaim = Console.ReadLine(); newCLaim.DateOfClaim = DateTime.Parse(dateOfClaim); Console.WriteLine("Is this claim valid? True or False"); string claimValid = Console.ReadLine(); newCLaim.IsValid = bool.Parse(claimValid); _claimRepo.AddClaimToQueue(newCLaim); }
//private void Validity() //{ // _claimRepo.ClaimValidity(); //} private void EnterNewClaim() { Console.WriteLine("Please enter the claim ID"); int claimID = ParseInput(); Console.WriteLine("Please select your claim type:\n" + "1. Car\n" + "2. Home\n" + "3. Theft"); int claimType = ParseInput(); ClaimType type; switch (claimType) { default: case 1: type = ClaimType.Car; break; case 2: type = ClaimType.Home; break; case 3: type = ClaimType.Theft; break; } Console.WriteLine("Please enter a claim description"); string description = Console.ReadLine(); Console.WriteLine("Please enter the claim amount"); decimal claimAmount = decimal.Parse(Console.ReadLine()); Console.WriteLine("Please enter the date of the accident (dd/mm/yy)"); DateTime dateOfIncident = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Please enter the date of the claim (dd/mm/yy)"); DateTime dateOfClaim = DateTime.Parse(Console.ReadLine()); ClaimInformation claim = new ClaimInformation(claimID, type, description, claimAmount, dateOfIncident, dateOfClaim); _claimRepo.AddClaimToQueue(claim); Console.WriteLine($"\"Claim ID#{claim.ClaimID}\" has been added to the list."); Console.ReadKey(); }
private void AddAClaim() { Console.Clear(); Claim newClaim = new Claim(); Console.WriteLine("What type of claim is this?\n" + "1. Car\n" + "2. Home\n" + "3. Theft\n"); int typeClaim = int.Parse(Console.ReadLine()); switch (typeClaim) { case 1: newClaim.ClaimType = ClaimType.Car; break; case 2: newClaim.ClaimType = ClaimType.Home; break; case 3: newClaim.ClaimType = ClaimType.Theft; break; } Console.WriteLine("What is the claim description?"); newClaim.Description = Console.ReadLine(); Console.WriteLine("What is the claim amount? Please use numerical values."); newClaim.Amount = decimal.Parse(Console.ReadLine()); DateTime incidentDate = new DateTime(); DateTime claimDate = new DateTime(); Incident: Console.WriteLine("Write the date of the incident in MM/DD/YYYY format:"); if (DateTime.TryParse(Console.ReadLine(), out incidentDate)) { newClaim.DateOfIncident = incidentDate; } else { Console.WriteLine("There was a formatting error, please try again."); goto Incident; } ClaimDate: Console.WriteLine("Write the date of the claim in MM/DD/YYYY format:"); if (DateTime.TryParse(Console.ReadLine(), out claimDate)) { newClaim.DateOfClaim = claimDate; } else { Console.WriteLine("There was a formatting error, please try again."); goto ClaimDate; } newClaim.IsValid = _repo.IsThisClaimValid(newClaim); _repo.AddClaimToQueue(newClaim); }