Ejemplo n.º 1
0
        void DataFeed_NewLevel2(string dataFeed, TimeZoneInfo aTZI, Level2Data level2)
        {
            Level2Subscribers aSubscribers;

            lock (m_Level2SubscribersBySymbols)
            {
                m_Level2SubscribersBySymbols.TryGetValue(level2.Symbol, out aSubscribers);
            }
            if (aSubscribers == null)
            {
                return;
            }

            List <string> aUsers;

            lock (aSubscribers)
            {
                aUsers = new List <string>(aSubscribers.Subscribers);
            }
            foreach (string item in aUsers)
            {
                var response = new L2SubscribeResponse
                {
                    Level2 = level2,
                    User   = DataServer.MessageRouter.gMessageRouter.GetUserInfo(item),
                };
                PushResponses(item, new ResponseMessage[] { response });
            }
        }
        /// <summary>
        /// occurs when data feed sends a quote
        /// </summary>
        ///
        void OnDdfClient_NewQuote(object sender, Client.NewQuoteEventArgs e)
        {
            try
            {
                string     aSymbolName;
                Instrument aType;
                Session    session = e.Quote.Sessions[Sessions.Combined];
                if (!TryParse(e.Quote.Symbol, out aSymbolName, out aType))
                {
                    return;
                }

                if (NewQuote != null && m_SubscribedSymbol.Contains(aSymbolName))
                {
                    SymbolItem aSymbol = new SymbolItem()
                    {
                        DataFeed = Name, Exchange = MarketName, Symbol = aSymbolName, Type = aType
                    };
                    NewQuote(Name, this.TimeZoneInfo, new Tick
                    {
                        Symbol = aSymbol,
                        //Date = e.Quote.Timestamp.ToUniversalTime(),
                        Date    = TimeZoneInfo.ConvertTimeToUtc(e.Quote.Timestamp, TimeZoneInfo),
                        Price   = session == null ? (e.Quote.Ask + e.Quote.Bid) / 2 : session.Last,
                        Volume  = session == null ? 0 : session.LastSize,
                        Bid     = e.Quote.Bid,
                        BidSize = e.Quote.BidSize,
                        Ask     = e.Quote.Ask,
                        AskSize = e.Quote.AskSize
                    });
                }

                if (NewLevel2 != null && m_Level2SubscribedSymbol.Contains(aSymbolName))
                {
                    SymbolItem aSymbol = new SymbolItem()
                    {
                        DataFeed = Name, Exchange = MarketName, Symbol = aSymbolName, Type = aType
                    };

                    Level2Data level2 = new Level2Data();
                    level2.Symbol = aSymbol;
                    level2.Asks   = new Level2Item[] { new Level2Item {
                                                           MarketMaker = Level1MarketMaker,
                                                           Price       = e.Quote.Ask,
                                                           Quantity    = (int)e.Quote.AskSize
                                                       } };
                    level2.Bids = new Level2Item[] { new Level2Item {
                                                         MarketMaker = Level1MarketMaker,
                                                         Price       = e.Quote.Bid,
                                                         Quantity    = (int)e.Quote.BidSize
                                                     } };

                    NewLevel2(Name, this.TimeZoneInfo, level2);
                }
            }
            catch (Exception ex)
            {
                WriteToLog("---OnDdfClient_NewQuote Exception", ex);
            }
        }
Ejemplo n.º 3
0
        public ActionResult Level2Post()
        {
            if (!CheckAuthCookie())
            {
                return(View("Level2AuthFailed"));
            }

            Level2Data data = null;

            using (var inputStream = new StreamReader(Request.InputStream))
            {
                try
                {
                    data = javaScriptSerializer.Deserialize <Level2Data>(inputStream.ReadToEnd());
                }
                catch (Exception)
                {
                    return(View("Level2BadJson"));
                }
            }

            if (data == null || data.hacker != "true")
            {
                return(View("Level2WrongParameter"));
            }

            if (!IsCsrf())
            {
                return(View("Level2NotCsrf"));
            }

            var cookie = new HttpCookie(Level2CompletedCookieName, Level2CompletedKey)
            {
                HttpOnly = true,
                Path     = Url.Action("Level2"),
                Expires  = DateTime.UtcNow.AddMonths(1)
            };

            Response.SetCookie(cookie);
            return(View("Level2Success"));
        }
Ejemplo n.º 4
0
            internal static Level2Data GetLevel2Data(Hashtable properties)
            {
                if (properties == null)
                {
                    throw new ArgumentNullException("properties");
                }

                Level2Data level2Data = null;

                PaymentProperty[] level2DataPropertyArray;
                if (PaymentProperty.GetPropertyValue(properties, GenericNamespace.PurchaseLevelData, PurchaseLevelDataProperties.L2Data, out level2DataPropertyArray))
                {
                    Hashtable level2DataProperties = PaymentProperty.ConvertToHashtable(level2DataPropertyArray);

                    level2Data = new Level2Data();
                    level2Data.OrderDateTime              = PaymentUtilities.GetPropertyDateTimeValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.OrderDateTime);
                    level2Data.OrderNumber                = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.OrderNumber);
                    level2Data.InvoiceDateTime            = PaymentUtilities.GetPropertyDateTimeValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.InvoiceDateTime);
                    level2Data.InvoiceNumber              = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.InvoiceNumber);
                    level2Data.OrderDescription           = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.OrderDescription);
                    level2Data.SummaryCommodityCode       = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.SummaryCommodityCode);
                    level2Data.MerchantContact            = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantContact);
                    level2Data.MerchantTaxId              = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantTaxId);
                    level2Data.MerchantType               = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantType);
                    level2Data.PurchaserId                = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.PurchaserId);
                    level2Data.PurchaserTaxId             = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.PurchaserTaxId);
                    level2Data.ShipToCity                 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToCity);
                    level2Data.ShipToCounty               = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToCounty);
                    level2Data.ShipToState_ProvinceCode   = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToState_ProvinceCode);
                    level2Data.ShipToPostalCode           = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToPostalCode);
                    level2Data.ShipToCountryCode          = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToCountryCode);
                    level2Data.ShipFromCity               = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromCity);
                    level2Data.ShipFromCounty             = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromCounty);
                    level2Data.ShipFromState_ProvinceCode = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromState_ProvinceCode);
                    level2Data.ShipFromPostalCode         = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromPostalCode);
                    level2Data.ShipFromCountryCode        = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromCountryCode);
                    level2Data.DiscountAmount             = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.DiscountAmount);
                    level2Data.MiscCharge                 = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MiscCharge);
                    level2Data.DutyAmount                 = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.DutyAmount);
                    level2Data.FreightAmount              = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.FreightAmount);
                    level2Data.IsTaxable              = PaymentUtilities.GetPropertyBooleanValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.IsTaxable);
                    level2Data.TotalTaxAmount         = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TotalTaxAmount);
                    level2Data.TotalTaxRate           = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TotalTaxRate);
                    level2Data.MerchantName           = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantName);
                    level2Data.MerchantStreet         = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantStreet);
                    level2Data.MerchantCity           = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantCity);
                    level2Data.MerchantState          = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantState);
                    level2Data.MerchantCounty         = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantCounty);
                    level2Data.MerchantCountryCode    = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantCountryCode);
                    level2Data.MerchantZip            = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantZip);
                    level2Data.TaxRate                = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxRate);
                    level2Data.TaxAmount              = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxAmount);
                    level2Data.TaxDescription         = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxDescription);
                    level2Data.TaxTypeIdentifier      = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxTypeIdentifier);
                    level2Data.RequesterName          = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.RequesterName);
                    level2Data.TotalAmount            = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TotalAmount);
                    level2Data.PurchaseCardType       = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.PurchaseCardType);
                    level2Data.AmexLegacyDescription1 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.AmexLegacyDescription1);
                    level2Data.AmexLegacyDescription2 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.AmexLegacyDescription2);
                    level2Data.AmexLegacyDescription3 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.AmexLegacyDescription3);
                    level2Data.AmexLegacyDescription4 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.AmexLegacyDescription4);

                    level2Data.TaxDetails           = PaymentUtilities.GetTaxDetails(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxDetails);
                    level2Data.MiscellaneousCharges = PaymentUtilities.GetMiscellaneousCharges(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MiscellaneousCharges);
                }

                return(level2Data);
            }
Ejemplo n.º 5
0
        /// <summary>
        /// Generate level 1 data
        /// </summary>
        private void ThreadFunc_RealTimeGenerator()
        {
            while (true)
            {
                List <SymbolItem> aList;

                lock (m_SubscribeSymbol)
                {
                    aList = new List <SymbolItem>(m_SubscribeSymbol);
                }
                foreach (SymbolItem item in aList)
                {
                    Tick tick = new Tick
                    {
                        Symbol = new SymbolItem()
                        {
                            DataFeed = Name, Exchange = MarketName, Symbol = item.Symbol, Type = item.Type
                        },
                        Date = DateTime.UtcNow
                    };

                    double lastPrice = GetLastPrice(item);


                    tick.Price   = lastPrice;
                    tick.Bid     = lastPrice - (double)m_Random.Next(10) / 1000;
                    tick.BidSize = m_Random.Next(10000);
                    tick.Ask     = lastPrice + (double)m_Random.Next(10) / 1000;
                    tick.AskSize = m_Random.Next(10000);
                    tick.Volume  = m_Random.Next(1000000);

                    int realtimeStep;
                    lock (m_RealtimeStep)
                    {
                        if (!m_RealtimeStep.TryGetValue(item, out realtimeStep))
                        {
                            realtimeStep = 0;
                        }
                    }

                    if (realtimeStep != 0)
                    {
                        lastPrice = lastPrice + (realtimeStep >= 0 ? 1 : -1) * (double)m_Random.Next(50) / 100;
                    }
                    else
                    {
                    }
                    lock (m_LastPrice)
                    {
                        m_LastPrice[item] = lastPrice;
                    }

                    if (realtimeStep == 0)
                    {
                        //
                        double askMultiply = GetRealtimeTrend(item);
                        //
                        realtimeStep = ((tick.Ask - tick.Price) * askMultiply >= (tick.Price - tick.Bid) / askMultiply ? 1 : -1) * m_Random.Next(10, 100) / 10;
                    }
                    else
                    {
                        if (realtimeStep < 0)
                        {
                            realtimeStep += 1;
                        }
                        else
                        {
                            realtimeStep -= 1;
                        }
                    }
                    lock (m_RealtimeStep)
                    {
                        m_RealtimeStep[item] = realtimeStep;
                    }

                    if (NewQuote != null)
                    {
                        NewQuote(Name, this.TimeZoneInfo, tick);
                    }
                }

                lock (m_Level2SubscribeSymbol)
                {
                    aList = new List <SymbolItem>(m_Level2SubscribeSymbol);
                }
                foreach (SymbolItem item in aList)
                {
                    double lastPrice = GetLastPrice(item);

                    Level2Data level2 = new Level2Data
                    {
                        Symbol = new SymbolItem()
                        {
                            DataFeed = Name, Exchange = MarketName, Symbol = item.Symbol, Type = item.Type
                        },
                        Asks = new List <Level2Item>(),
                        Bids = new List <Level2Item>()
                    };
                    foreach (var mm in m_MarketMakers)
                    {
                        level2.Asks.Add(new Level2Item {
                            MarketMaker = mm,
                            Price       = lastPrice + (double)m_Random.Next(10) / 1000,
                            Quantity    = m_Random.Next(10000)
                        });
                        level2.Bids.Add(new Level2Item {
                            MarketMaker = mm,
                            Price       = lastPrice - (double)m_Random.Next(10) / 1000,
                            Quantity    = m_Random.Next(10000)
                        });
                    }
                    if (NewLevel2 != null)
                    {
                        NewLevel2(Name, this.TimeZoneInfo, level2);
                    }
                }

                Thread.Sleep(300);
            }
        }
        public static Level2Data SetLevel2Data()
        {
            Level2Data L2 = new Level2Data();
            L2.BaseAmount = 10.00M; //Required : Base amount of the transaction, not including freight, handling, and tax amounts.
            //L2.CommodityCode = ""; //Optional : Commodity code for the entire purchase.
            //L2.CompanyName = ""; //Optional : Name of company making purchase.
            //L2.CustomerCode = ""; //Optional : Provided by cardholder to appear on invoice.
            //L2.Description = ""; //Optional : Description of the purchase.
            //L2.DestinationCountryCode = TypeISOCountryCodeA3.USA; //Optional : Specifies the destination country code of the goods being shipped.
            L2.DestinationPostal = "80040";//(Required) Specifies the destination postal code.
            //L2.DiscountAmount = 1.00M;
            //L2.DutyAmount = 2.00M; //Optional : Specifies duty amount.
            //L2.FreightAmount = 3.00M; //Optional : Specifies freight amount.
            //L2.MiscHandlingAmount = 4.00M; //Optional : Miscellaneous handling charges.
            //L2.OrderDate = DateTime.utcNow(); //Optional : Date the order was placed.
            L2.OrderNumber = "1235";//Required : Indicates the Order Number.
            //L2.RequesterName = "Don"; //Optional : Name of the person making the request.
            L2.ShipFromPostalCode = "94566";//(Required) The zip/postal code of the location from which the goods are shipped.
            L2.ShipmentId = "12DDER"; //Optional : Number of the shipment.

            L2.TaxExempt = new TaxExempt(); //Optional : Tax exemption indicator and number.
            L2.TaxExempt.IsTaxExempt = IsTaxExempt.NotExemptTaxInfoProvided;//Required : Indicates tax exempt status for the transaction.
            L2.TaxExempt.TaxExemptNumber = "123jsd"; //Conditional : Indicates tax exempt number for the transaction. Conditional, required if TaxExemptInd = 'Exempt' or 'Not_Exempt_Tax_Info_Provided'.

            //The following is used if the "IsTaxExempt" is not "Exempt"
            L2.Tax = new Tax(); //Optional : Aggregate of tax information.
            L2.Tax.Amount = 1.00M; //Required : Total amount of tax applied.
            L2.Tax.Rate = 1.00M; //Optional : Total tax rate.
            L2.Tax.InvoiceNumber = ""; //Optional : Tax invoice number.

            List<ItemizedTax> ITxs = new List<ItemizedTax>(); //Optional : Collection of itemized tax information.
            //ItemizedTax ITX = new ItemizedTax();
            //ITX.Amount = 0.05M; //Required : Amount of specified tax applied.
            //ITX.Rate = 0.02M; //Optional : Rate for tax specified.
            //ITX.Type = TypeTaxType.StateSalesTax; //Required : Type of tax specified.
            //ITxs.Add(ITX);
            L2.Tax.ItemizedTaxes = ITxs;

            return L2;
        }
Ejemplo n.º 7
0
        static void Level4()
        {
            string[] Level1 = File.ReadAllLines(LEVEL1);
            string[] Level2 = File.ReadAllLines(LEVEL2);
            string[] Level3 = File.ReadAllLines(LEVEL3);
            string[] Level4 = File.ReadAllLines(LEVEL4);

            Console.WriteLine("Please enter your Principle ID: ");
            string ID = Console.ReadLine();

            Console.Clear();
            foreach (string PrincipleData in Level4)
            {
                if (PrincipleData.StartsWith(ID))
                {
                    string[] Teachers = PrincipleData.Split(',');
                    FindTeacher(ID, Teachers);

                    Console.WriteLine("\n\nOptions:\n1. View All Students\n2. Add a Student\n5. View All Teachers\n6. Add a Teacher\n\nPlease select an option: ");
                    int option = Convert.ToInt16(Console.ReadLine());
                    Console.Clear();

                    if (option.Equals(1))
                    {
                        Console.WriteLine("Please select the students level category: ");
                        int studentlevel = Convert.ToInt16(Console.ReadLine());
                        Console.Clear();

                        if (studentlevel == 1 || studentlevel == 2)
                        {
                            if (studentlevel == 1)
                            {
                                foreach (string Level1Data in Level1)
                                {
                                    string[] LevelStudents = Level1Data.Split(',');
                                    Console.WriteLine($"Student ID: {LevelStudents[0]}\nStudent Name: {LevelStudents[1]} {LevelStudents[2]}\nStudent Superpower: {LevelStudents[3]}\nStudent Level: {LevelStudents[4]}\nStudent Course: {LevelStudents[5]}\nStudent Training: {LevelStudents[6]}\n");
                                }
                                Console.ReadLine();
                                break;
                            } //if
                            else
                            {
                                foreach (string Level2Data in Level2)
                                {
                                    string[] LevelStudents = Level2Data.Split(',');
                                    Console.WriteLine($"Student ID: {LevelStudents[0]}\nStudent Name: {LevelStudents[1]} {LevelStudents[2]}\nStudent Superpower: {LevelStudents[3]}\nStudent Level: {LevelStudents[4]}\nStudent Course: {LevelStudents[5]}\nStudent Training: {LevelStudents[6]}\n");
                                }
                                Console.ReadLine();
                                break;
                            } //else
                        }     //if
                        else
                        {
                            Console.WriteLine("Not a valid student level");
                            Console.ReadLine();
                            break;
                        }//else
                    }

                    if (option.Equals(2))
                    {
                        Student student = new Student();

                        //Add Student
                        Console.WriteLine("Please enter user ID: ");
                        student.ID = Convert.ToInt16(Console.ReadLine());
                        Console.Clear();

                        Console.WriteLine("Please enter first name: ");
                        student.FirstName = Console.ReadLine().ToUpper();
                        Console.Clear();

                        Console.WriteLine("Please enter last name: ");
                        student.LastName = Console.ReadLine().ToUpper();
                        Console.Clear();

                        Console.WriteLine("Please enter super power: ");
                        student.Superpower = Console.ReadLine().ToUpper();
                        Console.Clear();

                        Console.WriteLine("Please enter level: ");
                        student.Level = Convert.ToInt16(Console.ReadLine());
                        Console.Clear();

                        Console.WriteLine("Please enter course: ");
                        student.Courses = Console.ReadLine().ToUpper();
                        Console.Clear();

                        Console.WriteLine("Please enter training: ");
                        student.Training = Console.ReadLine().ToUpper();
                        Console.Clear();

                        StreamWriter Level1Writer = new StreamWriter(LEVEL1, append: true);
                        StreamWriter Level2Writer = new StreamWriter(LEVEL2, append: true);

                        if (student.Level.Equals(1))
                        {
                            Level1Writer.WriteLine($"{student.ID},{student.FirstName},{student.LastName},{student.Superpower},{student.Level},{student.Courses},{student.Training}");
                            Level1Writer.Close();
                            break;
                        }
                        if (student.Level.Equals(2))
                        {
                            Level2Writer.WriteLine($"{student.ID},{student.FirstName},{student.LastName},{student.Superpower},{student.Level},{student.Courses},{student.Training}");
                            Level2Writer.Close();
                            break;
                        }

                        else
                        {
                            Console.WriteLine("Invalid level for student");
                            Console.ReadLine();
                            break;
                        }
                    }

                    if (option.Equals(5))
                    {
                        foreach (string Level3Data in Level3)
                        {
                            string[] LevelStudents = Level3Data.Split(',');
                            Console.WriteLine($"Teacher ID: {LevelStudents[0]}\nTeacher Name: {LevelStudents[1]} {LevelStudents[2]}\nTeacher Superpower: {LevelStudents[3]}\nTeacher Level: {LevelStudents[4]}\nType of Teacher: {LevelStudents[5]}\nTeacher Salary: {LevelStudents[6]}\n");
                        }
                        Console.ReadLine();
                        break;
                    }

                    if (option.Equals(6))
                    {
                        Teacher teacher = new Teacher();

                        //Add Teacher
                        Console.WriteLine("Please enter user ID: ");
                        teacher.ID = Convert.ToInt16(Console.ReadLine());
                        Console.Clear();

                        Console.WriteLine("Please enter first name: ");
                        teacher.FirstName = Console.ReadLine().ToUpper();
                        Console.Clear();

                        Console.WriteLine("Please enter last name: ");
                        teacher.LastName = Console.ReadLine().ToUpper();
                        Console.Clear();

                        Console.WriteLine("Please enter super power: ");
                        teacher.Superpower = Console.ReadLine().ToUpper();
                        Console.Clear();

                        Console.WriteLine("Please enter level: ");
                        teacher.Level = Convert.ToInt16(Console.ReadLine());
                        Console.Clear();

                        Console.WriteLine("Please enter type of teacher: ");
                        teacher.TypeOfTeacher = Console.ReadLine().ToUpper();
                        Console.Clear();

                        Console.WriteLine("Please enter salary: ");
                        teacher.Salary = Convert.ToDouble(Console.ReadLine());
                        Console.Clear();

                        StreamWriter Level3Writer = new StreamWriter(LEVEL3, append: true);

                        if (teacher.Level.Equals(3))
                        {
                            Level3Writer.WriteLine($"{teacher.ID},{teacher.FirstName},{teacher.LastName},{teacher.Superpower},{teacher.Level},{teacher.TypeOfTeacher},{teacher.Salary}");
                            Level3Writer.Close();
                            break;
                        }

                        else
                        {
                            Console.WriteLine("Invalid level for teacher");
                            Console.ReadLine();
                            break;
                        }
                    }

                    else
                    {
                        Console.WriteLine("No valid option selected");
                        Console.ReadLine();
                    }
                    break;
                }
            }
        }
Ejemplo n.º 8
0
    public override LevelDataBase Save()
    {
        LevelDataBase level2 = new Level2Data();

        return(level2);
    }