コード例 #1
0
ファイル: HomeModule.cs プロジェクト: Rick1970/cdorganizer
        public HomeModule()
        {
            Get["/"] =_=> {
              return View["index.cshtml"];
            };
            Get["/addNew"] = _ =>{
              return View["addNew.cshtml"];
            };
            Get["/allCds"] = _ =>{
              List<Cd> allcds = Cd.GetAll();
              return View["allCds.cshtml",allcds];
            };
            Get["/searchByArtist"] = _ =>{
              return View["searchByArtist.cshtml"];
            };

            Get["/result"] = _ =>{
              List<Cd> invCd = Cd.Find(Request.Query["search-artist"]);
              return View["searchResult.cshtml",invCd];
            };
            Post["/add_new"] = _ =>{
              Cd oneCd = new Cd(Request.Form["artist"],Request.Form["title"]);
              return View["add_one.cshtml",oneCd];
            };
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: RikLaa/Demo04
        static void Main(string[] args)
        {
            Floppy diskette = new Floppy();
            diskette.Type = "Floppy";
            diskette.Size = 1.44;
            diskette.SaveData();
            diskette.Color = "Green";
            Console.WriteLine(diskette.ToString());

            Cd Roadrunner = new Cd();
            Roadrunner.Artist = "Hurriganes";
            Roadrunner.Type = "Audio cd";
            Roadrunner.Size = 800;
            Roadrunner.TrackNumber = 11;
            Roadrunner.TrackNumber = 30;
            Console.WriteLine(Roadrunner.ToString());

            Dvd Movie = new Dvd();
            Movie.Type = "Movie DVD";
            Movie.MovieName = "The Revenant";
            Movie.Size = 50000;
            Movie.DualLayer = true;
            Movie.SaveData();
            Movie.SaveData();
            Console.WriteLine(Movie.ToString());

            Console.ReadLine();
        }
コード例 #3
0
        /// <exception cref="System.IO.IOException"></exception>
        public override char[] ReadCharArray(string fieldName)
        {
            var fd = Cd.GetField(fieldName);

            if (fd == null)
            {
                return(null);
            }
            if (fd.GetFieldType() != FieldType.CharArray)
            {
                throw new IncompatibleClassChangeError();
            }
            return(base.ReadCharArray(fieldName));
        }
        /// <exception cref="System.IO.IOException"></exception>
        public override byte[] ReadByteArray(string fieldName)
        {
            var fd = Cd.GetField(fieldName);

            if (fd == null)
            {
                return(null);
            }
            if (fd.FieldType != FieldType.ByteArray)
            {
                throw new InvalidPortableFieldException();
            }
            return(base.ReadByteArray(fieldName));
        }
コード例 #5
0
        private static Displayable MapToCd(ElasticTitleIndex elasticProduct, Displayable displayable)
        {
            var cdItem = new Cd
            {
                StockLevel    = elasticProduct.StockLevel,
                MediaCount    = elasticProduct.MediaCount,
                Narrators     = elasticProduct.Narrator,
                RecordingType = elasticProduct.RecordingType,
            };
            Book book = (Book)cdItem;

            displayable = MapBookToDisplayable(elasticProduct, book);
            return(displayable);
        }
コード例 #6
0
ファイル: Test.cs プロジェクト: Mtt-linh/Sem2_Sharp
 static void Dcheck(List <Dinamond> Lists)
 {
     foreach (var Cd in Lists)
     {
         if (Cd.realOrFake())
         {
             System.Console.WriteLine("hang that");
         }
         else
         {
             System.Console.WriteLine("hang gia ");
         }
     }
 }
コード例 #7
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            Cd selectedCd = lbxCds.SelectedItem as Cd;

            if (selectedCd == null)
            {
                MessageBox.Show("Sie müssen eine Cd auswählen!");
            }

            Repository.GetInstance().RemoveCd(selectedCd);

            _cds = Repository.GetInstance().GetAllCds();
            lbxCds.ItemsSource = _cds;
        }
コード例 #8
0
        /// <exception cref="System.IO.IOException"></exception>
        public override byte ReadByte(string fieldName)
        {
            var fd = Cd.GetField(fieldName);

            if (fd == null)
            {
                return(0);
            }
            if (fd.GetFieldType() != FieldType.Byte)
            {
                throw new IncompatibleClassChangeError();
            }
            return(base.ReadByte(fieldName));
        }
コード例 #9
0
ファイル: HomeModules.cs プロジェクト: Sea413/Cd_File
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View ["index.cshtml"]);
     };
     Get["/new_Cd"] = _ => {
         return(View["new_cd.cshtml"]);
     };
     Post["/"] = _ => {
         Cd        newCd  = new Cd(Request.Form["Cd-Name"], Request.Form["Cd-Artist"]);
         List <Cd> Cdlist = Cd.GetAll();
         return(View["index.cshtml", Cdlist]);
     };
 }
コード例 #10
0
        /// <exception cref="System.IO.IOException"></exception>
        public override TPortable ReadPortable <TPortable>(string fieldName)
        {
            var fd = Cd.GetField(fieldName);

            if (fd == null)
            {
                return(default(TPortable));
            }
            if (fd.GetFieldType() != FieldType.Portable)
            {
                throw new IncompatibleClassChangeError();
            }
            return(base.ReadPortable <TPortable>(fieldName));
        }
コード例 #11
0
        /// <exception cref="System.IO.IOException"></exception>
        public override string ReadUTF(string fieldName)
        {
            var fd = Cd.GetField(fieldName);

            if (fd == null)
            {
                return(null);
            }
            if (fd.GetFieldType() != FieldType.Utf)
            {
                throw new IncompatibleClassChangeError();
            }
            return(base.ReadUTF(fieldName));
        }
コード例 #12
0
        /// <exception cref="System.IO.IOException"></exception>
        public override bool ReadBoolean(string fieldName)
        {
            var fd = Cd.GetField(fieldName);

            if (fd == null)
            {
                return(false);
            }
            if (fd.GetFieldType() != FieldType.Boolean)
            {
                throw new IncompatibleClassChangeError();
            }
            return(base.ReadBoolean(fieldName));
        }
コード例 #13
0
        public ActionResult List()
        {
            Cd newCd = new Cd(
                Request.Form["title"],
                Request.Form["artist"],
                Request.Form["price"]
                );

            newCd.Save();

            List <Cd> allCds = Cd.GetAll();

            return(View(allCds));
        }
コード例 #14
0
        /// <exception cref="System.IO.IOException"></exception>
        public override bool ReadBoolean(string fieldName)
        {
            var fd = Cd.GetField(fieldName);

            if (fd == null)
            {
                return(false);
            }
            if (fd.FieldType != FieldType.Boolean)
            {
                throw new InvalidPortableFieldException();
            }
            return(base.ReadBoolean(fieldName));
        }
コード例 #15
0
        /// <exception cref="System.IO.IOException"></exception>
        public override char ReadChar(string fieldName)
        {
            var fd = Cd.GetField(fieldName);

            if (fd == null)
            {
                return('\0');
            }
            if (fd.FieldType != FieldType.Char)
            {
                throw new InvalidPortableFieldException();
            }
            return(base.ReadChar(fieldName));
        }
コード例 #16
0
        // GET: Cds/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cd cd = (Cd)db.ItemBases.Find(id);

            if (cd == null)
            {
                return(HttpNotFound());
            }
            return(View(cd));
        }
コード例 #17
0
ファイル: CdTests.cs プロジェクト: bkiggen/CdBox.Solution
        public void GetAll_ReturnsCds_CdList()
        {
            string    artist1   = "Can";
            string    album1    = "Monster Movie";
            string    artist2   = "Nirvana";
            string    album2    = "Bleach";
            Cd        newCd1    = new Cd(artist1, album1);
            Cd        newCd2    = new Cd(artist2, album2);
            List <Cd> newCdList = new List <Cd> {
                newCd1, newCd2
            };
            List <Cd> result = Cd.GetAll();

            CollectionAssert.AreEqual(newCdList, result);
        }
コード例 #18
0
ファイル: Cd.cs プロジェクト: nlarion/cSharpPractice
  public static void Main()
  {
    Cd firstCd = new Cd("Master of Reality", "Black Sabbath", 10);
    Cd secondCd = new Cd("Electric Ladyland", "Jimi Hendrix", 10);
    Cd thirdCd = new Cd("Nevermind", "Nirvana", 10);

    List<Cd> Cds = new List<Cd>() { firstCd, secondCd, thirdCd };

    foreach (Cd album in Cds)
    {
      Console.WriteLine(album.Title);
      Console.WriteLine("By " + album.Artist);
      Console.WriteLine("Price: $" + album.Price);
    }
  }
コード例 #19
0
ファイル: CdTests.cs プロジェクト: bkiggen/CdBox.Solution
        public void Find_ReturnsCorrectCd_Cd()
        {
            string    artist1   = "Can";
            string    album1    = "Monster Movie";
            string    artist2   = "Nirvana";
            string    album2    = "Bleach";
            Cd        newCd1    = new Cd(artist1, album1);
            Cd        newCd2    = new Cd(artist2, album2);
            List <Cd> newCdList = new List <Cd> {
                newCd1, newCd2
            };
            Cd result = Cd.Find(2);

            Assert.AreEqual(newCd2, result);
        }
コード例 #20
0
        void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            Cd selectedCd = (Cd)lbxCds.SelectedItem;

            if (selectedCd == null)
            {
                MessageBox.Show("Sie müssen eine Cd auswählt haben");
            }

            Repository repository = Repository.GetInstance();

            repository.DeleteCd(selectedCd);
            _cds = repository.GetAllCds();
            lbxCds.ItemsSource = _cds;
        }
コード例 #21
0
        public void GenericsIteratorTest2()
        {
            CdRack cdRack = new CdRack();

            cdRack.AppendCd(new Cd("Thriller"));
            cdRack.AppendCd(new Cd("Back in Black"));
            cdRack.AppendCd(new Cd("Bat out of Hell"));
            cdRack.AppendCd(new Cd("The Dark Side of the Moon"));
            IIterator <Cd> it = cdRack.Iterator();

            while (it.HasNext())
            {
                Cd cd = it.Next();
                Debug.WriteLine(cd.Title);
            }
        }
コード例 #22
0
        public void UpdateCd(Cd cd)
        {
            using (var ctx = new ContextModel())
            {
                Genre     gen  = ctx.Genres.FirstOrDefault(x => x.ID == cd.Genre.ID);
                UserTable user = ctx.UserTables.FirstOrDefault(x => x.ID == cd.User.ID);

                Cd c = ctx.Cds.FirstOrDefault(x => x.ID == cd.ID);
                c.Name        = cd.Name;
                c.Description = cd.Description;
                c.Image       = cd.Image;
                c.Genre       = gen;
                c.User        = user;
                ctx.SaveChanges();
            }
        }
コード例 #23
0
        public HomeModule()
        {
            Get["/"] = _ => {
                var allCds = Cd.GetAll();
                return(View["All_cds.cshtml", allCds]);
            };
            Get["/add_cds"] = _ => {
                return(View["add_Cd.cshtml"]);
            };

            Post["/all_cd"] = _ => {
                var newCd  = new Cd(Request.Form["new-title"], Request.Form["new-artist"], Request.Form["new-price"]);
                var allCds = Cd.GetAll();
                return(View["All_cds.cshtml", allCds]);
            };
        }
コード例 #24
0
        private void addBookButton_Click(object sender, EventArgs e)
        {
            bool   allFeildsFull = true;
            string title         = titleTextBox.Text;

            if (title == "")
            {
                allFeildsFull = false;
            }
            string performer = performerTextBox.Text;

            if (performer == "")
            {
                allFeildsFull = false;
            }
            string producer = producerTextBox.Text;

            if (producer == "")
            {
                allFeildsFull = false;
            }
            string publisher = publisherTextBox.Text;

            if (publisher == "")
            {
                allFeildsFull = false;
            }
            // Only forms with all fields completed shall pass
            // If that is false, display an error message
            // and pause program
            if (allFeildsFull == false)
            {
                MessageBox.Show("ERROR! All fields must be filled out.");
            }
            else // All fields have data, so continue.
            {
                Cd cd = new Cd(title, performer, producer, publisher);
                media.Add(cd);

                // Let the user know the book was added successfully.
                MessageBox.Show(successString);
                titleTextBox.Text     = "";
                performerTextBox.Text = "";
                publisherTextBox.Text = "";
                producerTextBox.Text  = "";
            }
        }
コード例 #25
0
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            Cd selectedCd = lbxCds.SelectedItem as Cd;

            if (selectedCd == null)
            {
                MessageBox.Show("Sie müssen eine Cd auswählen!");
            }
            else
            {
                AddCdWindow addCdWindow = new AddCdWindow(selectedCd);
                addCdWindow.ShowDialog();
            }

            _cds = Repository.GetInstance().GetAllCds();
            lbxCds.ItemsSource = _cds;
        }
コード例 #26
0
        private void checkoutCdButton_Click(object sender, EventArgs e)
        {
            if (idTextBox.Text != "" && customerComboBox.SelectedIndex > -1)
            {
                int      cdId         = Convert.ToInt32(idTextBox.Text);
                Object   selectedItem = customerComboBox.SelectedItem;
                string   cId          = selectedItem.ToString();
                string[] id           = cId.Split(' ');
                int      customerId   = Convert.ToInt32(id[0]);
                foreach (Media c in mediaItems)
                {
                    if (c is Cd)
                    {
                        Cd itemAsCd = (Cd)c;
                        if (itemAsCd.Id == cdId)
                        {
                            if (!itemAsCd.IsCheckedOut())
                            {
                                itemAsCd.CheckOut();
                            }
                        }
                    }
                }
                bool success = true;

                if (success)
                {
                    MessageBox.Show(successString);
                    ClearCdFields();

                    mediaListView.Clear();

                    populateListView();
                    MediaController.PopulateMainCdsViewList(mediaListView, mediaItems);
                    customerComboBox.SelectedIndex = -1;
                }
                else
                {
                    MessageBox.Show(noSuccessString);
                }
            }
            else
            {
                MessageBox.Show(noSuccessString);
            }
        }
コード例 #27
0
        private void BtnDel_Clicked(object sender, RoutedEventArgs e)
        {
            rep = Repository.GetInstance();
            Cd selectedCd = (Cd)lbxCds.SelectedItem;

            if (selectedCd != null)
            {
                rep.RemoveCd(selectedCd);
            }
            else
            {
                MessageBox.Show("Wählen Sie CD zum Löschen");
            }

            _cds = rep.GetAllCds();
            lbxCds.ItemsSource = _cds;
        }
コード例 #28
0
        private void BtnEdit_Clicked(object sender, RoutedEventArgs e)
        {
            rep = Repository.GetInstance();
            Cd selectedCd = (Cd)lbxCds.SelectedItem;

            if (selectedCd != null)
            {
                EditCdWindow editCdWindow = new EditCdWindow(selectedCd);
                editCdWindow.ShowDialog();
            }
            else
            {
                MessageBox.Show("Wählen Sie eine CD zum Bearbeiten");
            }

            _cds = rep.GetAllCds();
            lbxCds.ItemsSource = _cds;
        }
コード例 #29
0
ファイル: Lambertian.cs プロジェクト: www1222/WPF-Ray-Tracing
        public override Vector3D SampleF(ref ShadeRec sr, ref Vector3D wo, out Vector3D wi, out double pdf)
        {
            Vector3D w = sr.Normal;
            Vector3D v = new Vector3D(0.0034, 1, 0.0071);

            v = v.CrossProduct(w);
            v = v.Normalize().ToVector3D();
            Vector3D u = v.CrossProduct(w);

            Vector3D sp = SamplerRef.SampleHemisphere();

            wi = sp.X * u + sp.Y * v + sp.Z * w;
            wi = wi.Normalize().ToVector3D();

            pdf = (float)(sr.Normal * wi * (1.0 / Math.PI));

            return(Cd.ScaleBy(Kd * (1.0 / Math.PI)));
        }
コード例 #30
0
        private void AddCdWindow_Loaded(object sender, RoutedEventArgs e)
        {
            btnSave.Click   += BtnSave_Click;
            btnCancel.Click += BtnCancel_Click;

            if (_cd == null)
            {
                DataContext = new Cd()
                {
                    AlbumTitle = "Bitte Titel eingeben",
                    Artist     = "Bitte Artist eingeben"
                };
            }
            else
            {
                DataContext = _cd;
            }
        }
コード例 #31
0
        private void AddCdWindow_Loaded(object sender, RoutedEventArgs e)
        {
            btnSave.Click   += BtnSave_Click;
            btnCancle.Click += BtnCancle_Click;

            if (_cd == null)
            {
                DataContext = new Cd
                {
                    AlbumTitle = "Bitte geben Sie hier den Titel ein!",
                    Artist     = "Bitte geben Sie hier den Artist ein"
                };
            }
            else
            {
                DataContext = _cd;
            }
        }
コード例 #32
0
ファイル: Cd.cs プロジェクト: nlarion/cSharpPractice
    public static void Main()
    {
        Cd firstCd  = new Cd("Master of Reality", "Black Sabbath", 10);
        Cd secondCd = new Cd("Electric Ladyland", "Jimi Hendrix", 10);
        Cd thirdCd  = new Cd("Nevermind", "Nirvana", 10);

        List <Cd> Cds = new List <Cd>()
        {
            firstCd, secondCd, thirdCd
        };

        foreach (Cd album in Cds)
        {
            Console.WriteLine(album.Title);
            Console.WriteLine("By " + album.Artist);
            Console.WriteLine("Price: $" + album.Price);
        }
    }
コード例 #33
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            _highlightedCd = listBoxCds.SelectedItem as Cd;

            Repository repository = Repository.GetInstance();

            if (_highlightedCd != null)
            {
                repository.DeleteCd(_highlightedCd);
            }
            else
            {
                MessageBox.Show("Keine CD ausgewählt!");
            }

            _cds = repository.GetAllCds();
            listBoxCds.ItemsSource = _cds;
        }
コード例 #34
0
        private static string GetExternalCdImageUri(Cd cd, bool isThumbnail)
        {
            // --------------------------- LAST.FM -------------------------
            var searchQuery = LastFmRepository.GetLastFmSearchQuery(cd);

            var lastFmAlbum = LastFmRepository.GetLastFmAlbumFromSeachQuery(searchQuery);

            if (lastFmAlbum != null){
                if (isThumbnail) return lastFmAlbum.SmallImageUrl;
                return lastFmAlbum.LargeImageUrl;
            }
            // --------------------------- END LAST.FM ---------------------
            
            // Here we can try other sources if available

            return string.Empty;
        }