Esempio n. 1
0
        protected void AddGsmButton_Click(object sender, EventArgs e)
        {
            string typeOfGsm = GsmtypeOfGSMTextBox.Text;
            string tTkofType = GsmtTKOfTypeTextBox.Text;

            if (CheckValues(typeOfGsm, tTkofType))
            {
                Gsm gsm = new Gsm
                {
                    TypeOfGsm = typeOfGsm,
                    TTkofType = tTkofType
                };

                _context.Gsm.Add(gsm);
                _context.SaveChanges();

                GsmtypeOfGSMTextBox.Text = string.Empty;
                GsmtTKOfTypeTextBox.Text = string.Empty;

                AddStatusLabel.Text = "Gsm was successfully added.";

                GsmGridView.PageIndex = GsmGridView.PageCount;
                GetGsm();
            }
        }
Esempio n. 2
0
        public static void CallHistoryTestPrint()
        {
            var myPhone = new Gsm(
                "THL", "China", "Niki", 200.5M, new Battery(BatteryType.Li_Ion, 60, 20), new Display(5.5M, 16000000));

            Console.WriteLine(myPhone);

            myPhone.AddCall(DateTime.Now, 0885998877, 65);
            myPhone.AddCall(DateTime.UtcNow, 0885665544, 98);
            myPhone.AddCall(DateTime.Now, 0885552277, 158);
            myPhone.AddCall(DateTime.Now, 0885996857, 112);
            myPhone.AddCall(DateTime.Now, 0885995827, 87);

            Console.WriteLine(myPhone.CallHistory);

            var priceInfo = new StringBuilder();

            priceInfo.AppendFormat("Total price: {0:C2}", myPhone.CallPrice());

            myPhone.RemoveLongestCall();

            priceInfo.AppendFormat(Environment.NewLine);
            priceInfo.AppendFormat("Longest Call removed");
            priceInfo.AppendFormat(Environment.NewLine);
            priceInfo.AppendFormat("Total price: {0:C2}", myPhone.CallPrice());

            myPhone.ClearCallHistory();

            Console.WriteLine(priceInfo);
            Console.WriteLine(myPhone.CallHistory);
        }
Esempio n. 3
0
        public async Task <IActionResult> Delete(int id, int page)
        {
            Gsm gsm = await context.Gsm.FindAsync(id);

            if (gsm == null)
            {
                return(NotFound());
            }

            bool   deleteFlag = false;
            string message    = "Do you want to delete this entity";

            if (context.Containers.Any(s => s.TypeOfGsmid == gsm.GSmid) && context.Costs.Any(s => s.TypeOfGsmid == gsm.GSmid))
            {
                message = "This entity has entities, which dependents from this. Do you want to delete this entity and other, which dependents from this?";
            }

            GsmViewModel gsmViewModel = new GsmViewModel();

            gsmViewModel.Gsm           = gsm;
            gsmViewModel.PageViewModel = new PageViewModel {
                PageNumber = page
            };
            gsmViewModel.DeleteViewModel = new DeleteViewModels {
                Message = message, IsDeleted = deleteFlag
            };

            return(View(gsmViewModel));
        }
Esempio n. 4
0
 public void TestGsmConstructor16_ThrowsException()
 {
     Gsm mobilePhone = new Gsm(
         MobilePhoneManufacturer.Unknown,
         null,
         null,
         "Motorola ATRIX HD MB886");
 }
Esempio n. 5
0
 public void TestGsmConstructor17_ThrowsException()
 {
     Gsm mobilePhone = new Gsm(
         MobilePhoneManufacturer.SonyEricsson,
         null,
         null,
         "");
 }
Esempio n. 6
0
 public static void PrintGsmInfo(Gsm gsm)
 {
     Console.WriteLine("Phone name: {0}", gsm.Name);
     Console.WriteLine("Height: {0}", gsm.Height);
     Console.WriteLine("Width: {0}", gsm.Width);
     Console.WriteLine("Weight: {0}", gsm.Weight);
     Console.WriteLine("Battery life: {0}", gsm.BatteryLife);
 }
Esempio n. 7
0
        public void TestGsmConstructor13()
        {
            Gsm mobilePhone = new Gsm(
                MobilePhoneManufacturer.Motorola,
                new Battery(),
                new Display(),
                "Motorola ATRIX HD MB886");

            Assert.AreEqual(null, mobilePhone.Battery.StandByTime.Hours);
        }
Esempio n. 8
0
        public void TestGsmConstructor14()
        {
            Gsm mobilePhone = new Gsm(
                MobilePhoneManufacturer.Motorola,
                null,
                new Display(),
                "Motorola ATRIX HD MB886");

            Assert.AreEqual(null, mobilePhone.Battery.TalkTime.Minutes);
        }
Esempio n. 9
0
        public void TestGsmConstructor15()
        {
            Gsm mobilePhone = new Gsm(
                MobilePhoneManufacturer.Motorola,
                null,
                null,
                "Motorola ATRIX HD MB886");

            Assert.AreEqual(null, mobilePhone.Display.Size.ResolutionWidth);
        }
Esempio n. 10
0
        public void TestGsmConstructor7()
        {
            Gsm mobilePhone = new Gsm(MobilePhoneManufacturer.Nokia,
                                      new Battery(BatteryType.LiIon, "BL-4U", 600, 0, 17, 0),
                                      new Display(240, 400, 3.0, ColorDepth.Colors65K),
                                      "Nokia Asha 310",
                                      90,
                                      "Dustin Hoffman");

            Assert.AreEqual(400, mobilePhone.Display.Size.ResolutionHeight);
        }
Esempio n. 11
0
        public void TestGsmConstructor5()
        {
            Gsm mobilePhone = new Gsm(MobilePhoneManufacturer.Nokia,
                                      new Battery(BatteryType.LiIon, "BL-4U", 600, 0, 17, 0),
                                      new Display(240, 400, 3.0, ColorDepth.Colors65K),
                                      "Nokia Asha 310",
                                      90,
                                      "Dustin Hoffman");

            Assert.AreEqual(17, mobilePhone.Battery.TalkTime.Hours);
        }
Esempio n. 12
0
        static void Main()
        {
            try
            {
                #region Programm hochfahren
                //Console.BufferHeight = 1000; //Max. Zeilen in Console begrenzen
                Console.WriteLine("Progammstart. Beenden mit >Exit> - Für Hilfe: >Help<");
                Ini.ReadIni();
                Console.WriteLine($"Tägliche Abfrage um {HourOfDailyTasks} Uhr.");

                //Modem initialisieren
                Gsm.SmsSentEvent              += Gsm_SmsSentEvent;
                Gsm.SmsRecievedEvent          += Gsm_SmsRecievedEvent;
                Gsm.GsmStatusReceived         += Gsm_GsmStatusReceived;
                Gsm.SmsSentFaildEvent         += Gsm_SmsSentFaildEvent;
                Gsm.SerialPortDisposed        += Gsm_SerialPortDisposed;
                Gsm.StatusReportRecievedEvent += Gsm_StatusReportRecievedEvent;
                Gsm.ModemSetup();

                Tab_Log.Insert(Tab_Log.Topic.Startup, 3, "Programmstart");

#if DEBUG
                Gsm.Debug = 7;
                Console.WriteLine("Debug: Es wird keine Info-Email beim Programmstart versendet.");
#else
                Email.Send(new System.Net.Mail.MailAddressCollection()
                {
                    Email.Admin
                }, DateTime.Now.ToString("G") + " MelBox2 Programmstart", "Information von " + Environment.MachineName);
#endif
                Console.WriteLine("Prüfe Datenbank: " + (Sql.CheckDb() ? "ok" : "Fehler"));

                MelBoxWeb.Server.Start();
                SetHourTimer();

                #endregion

                bool run = true;

                while (run)
                {
                    string request = Console.ReadLine() ?? string.Empty;
                    run = ParseConsoleInput(request);
                }
            }
            finally
            {
                Console.WriteLine("Das Programm wird beendet.");
                Gsm.Ask_DeactivateCallForewarding();
                MelBoxWeb.Server.Stop();
                Gsm.DisConnect();
            }
        }
Esempio n. 13
0
    public static void RunTests()
    {
        try
        {
            // create an instance of the Gsm class
            Gsm mobilePhone = new Gsm(
                MobilePhoneManufacturer.BlackBerry,
                new Battery(BatteryType.LiIon, null, 432, 0, 7, 0),
                new Display(320, 240, 2.44, ColorDepth.Colors65K),
                "BlackBerry Curve 9320",
                170,
                "Julia Roberts");

            // add a few calls
            mobilePhone.AddCallToHistory(2012, 8, 28, 13, 5, "00359 888 967584", 129);
            mobilePhone.AddCallToHistory(2012, 10, 15, 9, 34, "00359 878 900581", 907);
            mobilePhone.AddCallToHistory(2012, 12, 9, 2, 15, "00359 882 123456", 457);
            mobilePhone.AddCallToHistory(2013, 1, 7, 1, 57, "00359 883 969956", 307);
            mobilePhone.AddCallToHistory(2013, 2, 5, 10, 27, "00359 879 967584", 456);
            mobilePhone.AddCallToHistory(2013, 2, 12, 15, 45, "00359 885 962387", 812);

            // display call history
            Console.WriteLine("Call history:\n{0}", mobilePhone.GetCallHistory());

            // calculate total call price (given the price per minute)
            decimal totalCallPrice = mobilePhone.CalculateTotalCallPrice(0.37M);
            Console.WriteLine("Total call price: {0:N2}", totalCallPrice);

            // delete the longest call from history
            int callsRemoved = mobilePhone.DeleteLongestCallFromHistory();
            Console.WriteLine("{0} call(s) removed.", callsRemoved);

            // calculate total call price after deleting the longest call
            totalCallPrice = mobilePhone.CalculateTotalCallPrice(0.37M);
            Console.WriteLine("Total call price: {0:N2}", totalCallPrice);

            // clear call history
            mobilePhone.ClearCallHistory();

            // print the call history
            Console.WriteLine("Call history:\n{0}", mobilePhone.GetCallHistory());
        }
        catch (MobilePhoneException mpex)
        {
            Console.WriteLine(mpex.Message);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
Esempio n. 14
0
    static void Main()
    {
        decimal price = .37M;

        Gsm[] gsms = new Gsm[2];

        // GSM 0
        {
            gsms[0] = Gsm.IPhone4S;
        }

        // GSM 1
        {
            Display display = new Display(480, 900, 65000);
            Battery battery = new Battery(Battery.Type.LiIon, 50, 10);

            gsms[1] = new Gsm("Desire", "Htc", "Dido", 345.54m, display, battery);

            gsms[1].CallHistory.Add(new Call("234234", new TimeSpan(1, 7, 10))); // Hours, Minutes, Seconds
            gsms[1].CallHistory.Add(new Call("234142", new TimeSpan(0, 4, 20)));
            gsms[1].CallHistory.Add(new Call("2314234", new TimeSpan(1, 4, 0)));
            gsms[1].CallHistory.Add(new Call("42314256", new TimeSpan(0, 1, 20)));
        }

        // Print
        Console.WriteLine(gsms[0].ToString());
        Console.WriteLine();
        Console.WriteLine(gsms[1].ToString());
        Console.WriteLine();

        // CALL TEST
        CallHistoryTest callHistoryTest = new CallHistoryTest(gsms[1].CallHistory);

        // Calculate price
        callHistoryTest.GetPrice(price);

        // Remove call
        callHistoryTest.Remove(id: 2);

        // Calculate price
        callHistoryTest.GetPrice(price);

        // Remove longest call
        callHistoryTest.RemoveLongestCall();

        // Calculate price
        callHistoryTest.GetPrice(price);

        // Clear call history
        callHistoryTest.ClearHistory();
    }
Esempio n. 15
0
        protected void GsmGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var row = GsmGridView.Rows[e.RowIndex];
            int id  = int.Parse(row.Cells[1].Text);

            Gsm gsm = _context.Gsm.FirstOrDefault(g => g.GSmid == id);

            _context.Gsm.Remove(gsm);
            _context.SaveChanges();

            AddStatusLabel.Text = "Gsm was successfully deleted.";

            GetGsm();
        }
Esempio n. 16
0
        static void Main()
        {
            MelSql sql = new MelSql();

            sql.Log(MelBox.MelSql.LogTopic.Start, MelSql.LogPrio.Info, "Dies ist der erste Manuelle Eintrag.");

            sql.UpdateBlockedMessage(1, 8, 16, 7);

            sql.UpdateCompany(1, "_UNBEKANNT2_");

            sql.UpdateContact(2, MelSql.SendToWay.Email, "", 0, "", 4915142265412);

            sql.UpdateShift(1, DateTime.Now, DateTime.Now.AddHours(1));


            //-------------------------------------------------------------------------------------------------------
            Console.WriteLine("Öffne COM-Port...");
            Gsm gsm = new Gsm();

            gsm.RaiseGsmSystemEvent   += HandleGsmSystemEvent;
            gsm.RaiseGsmRecEvent      += HandleGsmRecEvent;
            gsm.RaiseGsmSentEvent     += HandleGsmSentEvent;
            gsm.RaiseSmsRecievedEvent += HandleSmsRecievedEvent;

            Console.WriteLine("Mobilfunktnetzerk " + (gsm.IsSimRegiserd() ? "registriert" : "kein Empfang"));

            int sig = gsm.GetSignalQuality();

            Console.WriteLine("Signalqualität " + sig + "%");

            Console.WriteLine("Abboniere neu ankommende SMS.");
            gsm.SubscribeNewSms();

            Console.WriteLine("Lese alle vorhandenen SMS:");
            gsm.ReadMessage();

            Console.WriteLine("Beliebige Taste zum beenden...");
            //Timer timer = new Timer(5000);
            //timer.Elapsed += Timer_Elapsed;
            //timer.Start();
            //while (!Console.KeyAvailable)
            //{
            //    // Infinite loop.
            //}

            //Console.WriteLine("COM-Port freigeben...");
            gsm.ClosePort();
            Console.WriteLine("beendet.");
            Console.ReadKey();
        }
Esempio n. 17
0
        public static void CallHistoryTest()
        {
            Gsm test2 = new Gsm("3310", "Nokia", 50.5M, "Gosho", new Battery("12345EN", 50, 30, BatteryType.Nickel_Cadmium), new Display(2.2, 16));

            test2.AddCall("13.03.2010", "16:10", "15429580239", 582);
            test2.AddCall("12.04.2011", "11:22", "31235513132", 1318);
            test2.AddCall("09.11.2012", "20:55", "65426527474", 310);

            Console.WriteLine(test2.CallHistory);
            Console.WriteLine(test2.GetTotalPrice());

            test2.DeleteLongestCall();
            Console.WriteLine(test2.GetTotalPrice());
            test2.DeleteAllCalls();
            Console.WriteLine(test2.GetTotalPrice());
        }
Esempio n. 18
0
        public void TestTotalCallPrice2()
        {
            // create an instance of the Gsm class
            Gsm mobilePhone = new Gsm(
                MobilePhoneManufacturer.BlackBerry,
                new Battery(BatteryType.LiIon, null, 432, 0, 7, 0),
                new Display(320, 240, 2.44, ColorDepth.Colors65K),
                "BlackBerry Curve 9320",
                170,
                "Julia Roberts");

            // calculate total call price (given the price per minute)
            decimal totalCallPrice = mobilePhone.CalculateTotalCallPrice(0.37M);

            Assert.AreEqual(0, totalCallPrice);
        }
Esempio n. 19
0
        //Problem 7
        public static void StartTest()
        {
            var samsung = new Gsm("Samsung", "S300");
            var nokia   = new Gsm("Nokia", "3310", BatteryType.NiCd, 30, "Pesho", "SKU1254", 150.5, 72.2, 1.6, 2);
            var sony    = new Gsm("Sony", "Xperia X", BatteryType.LiIon, 799.99, "Petar Petrov", null, null, null, 5, 16000000);
            var alcatel = new Gsm("Alcatel", "OT-363", BatteryType.LiIon, 99.99, "Ivan Ivanov", null, null, 2.5, 1.8, 65536);

            Gsm[] arr = { samsung, nokia, sony, alcatel };
            Console.WriteLine("Started instance test:\n");
            foreach (var gsm in arr)
            {
                Console.WriteLine(gsm.ToString());
            }
            Console.WriteLine("Started static test:\n");
            Console.WriteLine(Gsm.Iphone4S);
        }
Esempio n. 20
0
        public async Task <IActionResult> Edit(int id, int page)
        {
            Gsm gsm = await context.Gsm.FindAsync(id);

            if (gsm != null)
            {
                GsmViewModel gsmViewModel = new GsmViewModel();
                gsmViewModel.PageViewModel = new PageViewModel {
                    PageNumber = page
                };
                gsmViewModel.Gsm = gsm;

                return(View(gsmViewModel));
            }

            return(NotFound());
        }
Esempio n. 21
0
    /// <summary>
    /// For a complete list of the mobile phone brands, go to http://www.gsmarena.com/makers.php3
    /// </summary>
    public static void RunTests()
    {
        try
        {
            // create an array of instances of the Gsm class
            Gsm[] mobilePhones = new Gsm[]
            {
                new Gsm(
                    MobilePhoneManufacturer.Nokia,
                    new Battery(BatteryType.LiIon, "BL-4U", 600, 0, 17, 0),
                    new Display(240, 400, 3.0, ColorDepth.Colors65K),
                    "Nokia Asha 310",
                    90,
                    "Dustin Hoffman"),

                new Gsm(MobilePhoneManufacturer.Motorola, new Battery(), new Display(), "Motorola ATRIX HD MB886"),

                new Gsm(
                    MobilePhoneManufacturer.Microsoft,
                    new Battery(BatteryType.LiIon, "", null, null, 8, 0),
                    new Display(null, null, 10.6, ColorDepth.Colors16M),
                    "Microsoft Surface",
                    390,
                    "Robert De Niro")
            };

            // display information about each GSM in the array
            foreach (Gsm phone in mobilePhones)
            {
                Console.WriteLine("{0}\n", phone);
            }

            // display information about the static property IPhone4S
            Console.WriteLine(Gsm.IPhone4S);
        }
        catch (MobilePhoneException mpex)
        {
            Console.WriteLine(mpex.Message);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
Esempio n. 22
0
        static void Main()
        {
            decimal price = .37M;

            Gsm[] gsms = new Gsm[2];

            // GSM 0
            {
                gsms[0] = Gsm.IPhone4S;
            }

            // GSM 1
            {
                Display display = new Display(480, 320);
                Battery battery = new Battery(Battery.Type.LiIon);

                gsms[1] = new Gsm("iPhone 5", "Apple", display: display, battery: battery);

                gsms[1].CallHistory.Add(new Call("123", new TimeSpan(0, 1, 10))); // Hours, Minutes, Seconds
                gsms[1].CallHistory.Add(new Call("456", new TimeSpan(0, 2, 20)));
                gsms[1].CallHistory.Add(new Call("123", new TimeSpan(0, 2, 0)));
                gsms[1].CallHistory.Add(new Call("456", new TimeSpan(0, 1, 0)));
            }

            foreach (Gsm gsm in gsms)
            {
                GsmTest.Print(gsm);
            }

            CallHistoryTest callHistoryTest = new CallHistoryTest(gsms[1].CallHistory);

            callHistoryTest.GetPrice(price);

            callHistoryTest.Remove(id: 2);

            callHistoryTest.GetPrice(price);

            callHistoryTest.RemoveLongestCall();

            callHistoryTest.GetPrice(price);

            callHistoryTest.ClearHistory();
        }
        static void Main(string[] args)
        {
            var shop = new Shop();

            var fridge = new Fridge("KoelerMan", "X850", 180, "White");

            var microWave = new MicroWave("Philips", "Z50", 100, 950);

            var gsm = new Gsm("Nokia", "Stone of death", 350, true);

            shop.AddProduct(fridge);
            shop.AddProduct(microWave);
            shop.AddProduct(gsm);

            shop.AddProducts(fridge, microWave);

            shop.ShowAllProductDetails();

            Console.ReadLine();
        }
Esempio n. 24
0
        public async Task <IActionResult> Delete(GsmViewModel gsmViewModel)
        {
            bool   deleteFlag = true;
            string message    = "Do you want to delete this entity";
            Gsm    gsm        = await context.Gsm.FindAsync(gsmViewModel.Gsm.GSmid);

            gsmViewModel.DeleteViewModel = new DeleteViewModels {
                Message = message, IsDeleted = deleteFlag
            };
            if (gsm == null)
            {
                return(NotFound());
            }

            context.Gsm.Remove(gsm);
            await context.SaveChangesAsync();

            cache.Clean();
            return(View(gsmViewModel));
        }
        private void HandlePipeRecEvent(object sender, string e)
        {
            if (e.StartsWith("{"))
            {
                GsmEventArgs telegram = Gsm.JSONDeserializeTelegram(e);
                char[]       replace  = { '\r', '\n' };

                if (var.FilterEvents(telegram))
                {
                    LogItem log = new LogItem
                    {
                        Message      = telegram.Message.Replace("\r\n\r\n", "\r\n").Replace("\r\r\n", "\r\n").Trim(replace), //Zeilenumbrüche minimieren
                        MessageColor = Var.GetColorFromTelegram(telegram)
                    };

                    Dispatcher.Invoke(new Action(() => //Dispatcher ist notwendig, um im UI-Thread ändern zu können.
                                                 var.AddToTrafficList(log)
                                                 ));
                }
            }
        }
Esempio n. 26
0
        static void HandleSmsRecievedEvent(object sender, Sms e)
        {
            //Neue SMS-Nachricht empfangen
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("SMS empfangen:\r\n+" + e.Phone + ": " + e.Content);
            Console.ForegroundColor = ConsoleColor.Gray;

            PipeOut.SendToPipe(PipeNameOut, MelBoxGsm.Gsm.JSONSerialize(e));

            //Neue Nachricht in DB speichern
            int recMsgId = Sql.InsertRecMessage(e.Content, e.Phone);

            //Für jeden Empfänger (Bereitschaft) eine SMS vorbereiten
            foreach (ulong phone in Sql.GetCurrentShiftPhoneNumbers())
            {
                //Zu sendende Nachricht in DB protokollieren
                int sentId = Sql.InsertLogSent(phone, recMsgId);
                //Nachricht weiterleiten
                Gsm.SmsSend(phone, e.Content, sentId);
            }
        }
Esempio n. 27
0
        //Problem 12
        public static void StartTest()
        {
            var gsm = new Gsm("Samsung", "S300");

            gsm.AddCall("6/15/2009 1:45 PM", 50, "088889880");
            gsm.AddCall("7/16/2010 2:45 PM", 60, "088889861");
            gsm.AddCall("8/17/2011 3:45 PM", 70, "088889862");
            gsm.AddCall("9/18/2012 4:45 PM", 80, "088889863");
            gsm.AddCall("10/19/2014 6:45 PM", 1500, "088889865");
            gsm.AddCall("10/19/2013 5:45 PM", 100, "088889864");

            var longestCall = gsm.CallHistory[0];

            Console.WriteLine("Starting call history test:\n");
            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.DateTime);
                Console.WriteLine("Call duration in seconds: " + call.DurationInSeconds);
                Console.WriteLine("Call to: " + call.DialedNumber + "\n");

                if (longestCall.DurationInSeconds < call.DurationInSeconds)
                {
                    longestCall = call;
                }
            }
            Console.WriteLine("Total price of calls before removing longest: {0:F2}\n",
                              +gsm.GetTotalPriceOfCalls(PricePerMin));
            Console.WriteLine("Deleting longest call. Starting test:\n");
            gsm.DeleteCall(longestCall);

            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.DateTime);
                Console.WriteLine("Call duration in seconds: " + call.DurationInSeconds);
                Console.WriteLine("Call to: " + call.DialedNumber + "\n");
            }
            Console.WriteLine("Total price of calls after removing longest: {0:F2}\n",
                              +gsm.GetTotalPriceOfCalls(PricePerMin));
        }
Esempio n. 28
0
        protected void GsmGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string typeOfGsm = (string)e.NewValues["TypeOfGsm"];
            string tTkofType = (string)e.NewValues["TTkofType"];

            if (CheckValues(typeOfGsm, tTkofType))
            {
                var row = GsmGridView.Rows[e.RowIndex];
                int id  = int.Parse(row.Cells[1].Text);

                Gsm gsm = _context.Gsm.FirstOrDefault(g => g.GSmid == id);

                gsm.TypeOfGsm = typeOfGsm;
                gsm.TTkofType = tTkofType;

                _context.SaveChanges();

                AddStatusLabel.Text = "Gsm was successfully updated.";

                GsmGridView.EditIndex = -1;
                GetGsm();
            }
        }
Esempio n. 29
0
        public async Task <IActionResult> Edit(GsmViewModel gsmViewModel)
        {
            if (ModelState.IsValid)
            {
                Gsm gsm = context.Gsm.Find(gsmViewModel.Gsm.GSmid);
                if (gsm != null)
                {
                    gsm.TypeOfGsm = gsmViewModel.Gsm.TypeOfGsm;
                    gsm.TTkofType = gsmViewModel.Gsm.TTkofType;

                    context.Gsm.Update(gsm);
                    await context.SaveChangesAsync();

                    cache.Clean();
                    return(RedirectToAction("Index", "Gsm", new { page = gsmViewModel.PageViewModel.PageNumber }));
                }
                else
                {
                    return(NotFound());
                }
            }

            return(View(gsmViewModel));
        }
Esempio n. 30
0
        public void TestClearHistory()
        {
            // create an instance of the Gsm class
            Gsm mobilePhone = new Gsm(
                MobilePhoneManufacturer.BlackBerry,
                new Battery(BatteryType.LiIon, null, 432, 0, 7, 0),
                new Display(320, 240, 2.44, ColorDepth.Colors65K),
                "BlackBerry Curve 9320",
                170,
                "Julia Roberts");

            // add a few calls
            mobilePhone.AddCallToHistory(2012, 8, 28, 13, 5, "00359 888 967584", 129);
            mobilePhone.AddCallToHistory(2012, 10, 15, 9, 34, "00359 878 900581", 907);
            mobilePhone.AddCallToHistory(2012, 12, 9, 2, 15, "00359 882 123456", 457);
            mobilePhone.AddCallToHistory(2013, 1, 7, 1, 57, "00359 883 969956", 307);
            mobilePhone.AddCallToHistory(2013, 2, 5, 10, 27, "00359 879 967584", 456);
            mobilePhone.AddCallToHistory(2013, 2, 12, 15, 45, "00359 885 962387", 812);

            // clear call history
            mobilePhone.ClearCallHistory();

            Assert.AreEqual(String.Empty, mobilePhone.GetCallHistory());
        }
Esempio n. 31
0
        public void TestDeleteLongestCallFromHistory()
        {
            // create an instance of the Gsm class
            Gsm mobilePhone = new Gsm(
                MobilePhoneManufacturer.BlackBerry,
                new Battery(BatteryType.LiIon, null, 432, 0, 7, 0),
                new Display(320, 240, 2.44, ColorDepth.Colors65K),
                "BlackBerry Curve 9320",
                170,
                "Julia Roberts");

            // add a few calls
            mobilePhone.AddCallToHistory(2012, 8, 28, 13, 5, "00359 888 967584", 129);
            mobilePhone.AddCallToHistory(2012, 10, 15, 9, 34, "00359 878 900581", 907);
            mobilePhone.AddCallToHistory(2012, 12, 9, 2, 15, "00359 882 123456", 457);
            mobilePhone.AddCallToHistory(2013, 1, 7, 1, 57, "00359 883 969956", 307);
            mobilePhone.AddCallToHistory(2013, 2, 5, 10, 27, "00359 879 967584", 456);
            mobilePhone.AddCallToHistory(2013, 2, 12, 15, 45, "00359 885 962387", 907);

            // delete the longest call from history
            int callsRemoved = mobilePhone.DeleteLongestCallFromHistory();

            Assert.AreEqual(2, callsRemoved);
        }
Esempio n. 32
0
        public void TestTotalCallPrice1()
        {
            // create an instance of the Gsm class
            Gsm mobilePhone = new Gsm(
                MobilePhoneManufacturer.BlackBerry,
                new Battery(BatteryType.LiIon, null, 432, 0, 7, 0),
                new Display(320, 240, 2.44, ColorDepth.Colors65K),
                "BlackBerry Curve 9320",
                170,
                "Julia Roberts");

            // add a few calls
            mobilePhone.AddCallToHistory(2012, 8, 28, 13, 5, "00359 888 967584", 129);
            mobilePhone.AddCallToHistory(2012, 10, 15, 9, 34, "00359 878 900581", 907);
            mobilePhone.AddCallToHistory(2012, 12, 9, 2, 15, "00359 882 123456", 457);
            mobilePhone.AddCallToHistory(2013, 1, 7, 1, 57, "00359 883 969956", 307);
            mobilePhone.AddCallToHistory(2013, 2, 5, 10, 27, "00359 879 967584", 456);
            mobilePhone.AddCallToHistory(2013, 2, 12, 15, 45, "00359 885 962387", 812);

            // calculate total call price (given the price per minute)
            decimal totalCallPrice = mobilePhone.CalculateTotalCallPrice(0.37M);

            Assert.AreEqual(18.92M, Math.Round(totalCallPrice, 2));
        }