Exemplo n.º 1
0
    /// <summary>
    /// Given a player's Genre and the Genre of their attack, determines what Same Type Attack Bonus the player will get.
    /// </summary>
    /// <param name="ofPlayer">The Genre of the player.</param>
    /// <param name="ofAttack">The Genre of the weapon held by that player</param>
    /// <returns>Some bonus/penalty based on the inputs.</returns>
    public static float GetSameTypeBonus(Genre ofPlayer, Genre ofAttack)
    {
        switch (ofPlayer)
        {
            // Each case returns a STAB bonus based on how the attack's type compares to the user's.
            // Same type results in a 1.7x mult, the type that either counters or is countered by the player's type results
            // in a 0.6x mult, and the last "neutral" type results in a 1x mult (no change).
            case Genre.Fantasy:
                if(ofAttack == Genre.Fantasy)
                { return m_positiveSTABBonus; }
                else
                { return m_neutralSTABBonus; }

            case Genre.GraphicNovel:
                if(ofAttack == Genre.GraphicNovel)
                { return m_positiveSTABBonus; }
                else
                { return m_neutralSTABBonus; }

            case Genre.Horror:
                if (ofAttack == Genre.Horror)
                { return m_positiveSTABBonus; }
                else
                { return m_neutralSTABBonus; }

            case Genre.SciFi:
                if (ofAttack == Genre.SciFi)
                { return m_positiveSTABBonus; }
                else 
                { return m_neutralSTABBonus; }

            default:
                return 1f;
        }
    }
        public Genre Update(Genre genre)
        {
            dbContext.Entry(genre).State = EntityState.Modified;
            dbContext.SaveChanges();

            return genre;
        }
Exemplo n.º 3
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     bool isAlreadyExists;
     using (var context = new MyMoviesContext())
     {
         var genre = new Genre
         {
             Name = tbName.Text,
         };
         isAlreadyExists = context.Genres.FirstOrDefault(x => x.Name == genre.Name) != null;
         if (!isAlreadyExists)
         {
             context.Genres.Add(genre);
             context.SaveChanges();
         }
     }
     if (isAlreadyExists)
     {
         Response.Redirect(Request.Url.AbsoluteUri.Substring(0,
             Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count()) + "?genreAction=exist");
     }
     else
     {
         Response.Redirect("~/Default.aspx");
     }
 }
Exemplo n.º 4
0
        public void ShouldCreateGenreWithArtists()
        {
            Genre savedGenre = new Genre { Name = "Pop" };
            List<Artist> artists = new List<Artist> {
                    new Artist { Name = "1" },
                    new Artist { Name = "2" }
                };
            savedGenre.AddArtists(artists);
            Session.SaveOrUpdate(savedGenre);
            m_uow.Commit();
            Session.Clear();

            Genre retrievedGenre = Session.Get<Genre>(1);

            Assert.AreNotEqual(null, retrievedGenre);
            Assert.IsFalse(ReferenceEquals(savedGenre, retrievedGenre));
            Assert.AreEqual(savedGenre.Name, retrievedGenre.Name);
            Assert.AreEqual(savedGenre.Artists.Count, retrievedGenre.Artists.Count);
            Assert.IsFalse(ReferenceEquals(savedGenre.Artists[0], retrievedGenre.Artists[0]));
            Assert.AreEqual(savedGenre.Artists[0].Name, retrievedGenre.Artists[0].Name);
            Assert.IsFalse(ReferenceEquals(savedGenre.Artists[1], retrievedGenre.Artists[1]));
            Assert.AreEqual(savedGenre.Artists[1].Name, retrievedGenre.Artists[1].Name);

            //new PersistenceSpecification<Genre>(Session)
            //    .CheckProperty(g => g.Id, 1) //identity starts at 1 - can't reset to zero
            //    .CheckProperty(g => g.Name, "Genre")
            //    .CheckList(g => g.Artists, artists, (g, a) => g.AddArtist(a))
            //    .VerifyTheMappings();
        }
        public Genre Create(Genre genre)
        {
            dbContext.Genres.Add(genre);
            dbContext.SaveChanges();

            return genre;
        }
Exemplo n.º 6
0
        public void TestGenreDelete()
        {
            using (var ctx = new CDCatalogEntities())
            {
                //Test init
                Genre g = new Genre();
                g.GenreID = 0;  // auto incremented and set by add
                g.GenreName = "Test Genre W6YderKT";
                //add it to the context and save to database
                ctx.Genres.Add(g);
                ctx.SaveChanges();

                //Find the list of "Test Genre"
                //in case duplicates were added in the previous tests, delete them all
                var list = ctx.Genres
                .Where(n => n.GenreName.ToLower().Equals("test genre w6yderkt"))
                .Where(n => n.GenreID > 1000);

                ctx.Genres.RemoveRange(list);
                int count = ctx.SaveChanges();
                Assert.IsTrue(count > 0, "No Record Deleted");

                //Test clean-up (none)

            }
        }
Exemplo n.º 7
0
 public Movie()
 {
     Genres = new Genre[0];
     ProductionCompanies = new ProductionCompanyInfo[0];
     ProductionCountries = new Country[0];
     SpokenLanguages = new Language[0];
 }
Exemplo n.º 8
0
        public void TestGenreAdd()
        {
            //create a new context
            using (var ctx = new CDCatalogEntities())
            {
                //Test init

                //Create a test genre
                Genre g = new Genre();
                g.GenreID = 0;  // auto incremented and set by add
                g.GenreName = "Test Genre W6YderKT";
                //add it to the context
                ctx.Genres.Add(g);
                //verify that records were changed
                int count = ctx.SaveChanges();
                Assert.IsTrue(count > 0 && g.GenreID > 0, "No Records Changed");

                //Test clean-up
                if (count > 0)
                {
                    var list = ctx.Genres
                        .Where(n => n.GenreName.ToLower().Equals("test genre w6yderkt"))
                        .Where(n => n.GenreID > 0);

                    ctx.Genres.RemoveRange(list);
                    ctx.SaveChanges();
                }
            }
        }
Exemplo n.º 9
0
        public List<Genre> GetAll()
        {
            List<Genre> results = new List<Genre>();
            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("GenreGetAll",cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();

                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var genre = new Genre();
                        genre.GenreID = (int) dr["GenreID"];
                        genre.GenreName = dr["GenreName"].ToString();

                        results.Add(genre);
                    }
                }

            }

            return results;
        }
Exemplo n.º 10
0
		public async Task<Genre> GetGenres( CancellationToken cancellationToken )
		{
			if( _genres == null )
			{
				DateTime cacheModificationDate = await _dataCacheService.GetItemModificationDate( CacheItemName );

				if( (DateTime.Now - cacheModificationDate) < TimeSpan.FromDays( CacheAgeInDays ) )
				{
					try
					{
						_genres = _dataCacheService.GetItem<Genre>( CacheItemName );
					}
					catch (Exception ex)
					{
					    Debug.WriteLine(ex.Message);
					}
				}

				if( _genres == null )
				{
					_genres = await _client.GetGenres( cancellationToken );

					_dataCacheService.PutItem<Genre>( _genres, CacheItemName, cancellationToken );
				}
			}

			return _genres;
		}
Exemplo n.º 11
0
        public Story Create(string storyName, string creatorId, IEnumerable<string> genreNames)
        {
            var existingGenres = this.genreRepository.All()
                .Where(x => genreNames.Contains(x.Name))
                .ToList();

            foreach (var genre in genreNames)
            {
                if (!existingGenres.AsQueryable().Select(x => x.Name).Contains(genre))
                {
                    var newGenre = new Genre
                    {
                        Name = genre
                    };

                    existingGenres.Add(newGenre);
                    this.genreRepository.Add(newGenre);
                }
            }

            this.genreRepository.Save();

            var story = new Story
            {
                AuthorId = creatorId,
                Name = storyName,
                Genres = existingGenres
            };

            this.storyRepository.Add(story);
            this.storyRepository.Save();

            return this.storyRepository.All()
                .FirstOrDefault(x => x.Name == story.Name);
        }
Exemplo n.º 12
0
        public static Boolean delete(Genre genre)
        {
            Boolean isDelete = false;
            //Connection
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["EntretienSPPPConnectionString"];
            SqlConnection connection = new SqlConnection(connectionStringSettings.ToString());

            String requete = @"DELETE FROM genre WHERE Identifiant = @Identifiant ; ";

            SqlCommand commande = new SqlCommand(requete, connection);

            commande.Parameters.AddWithValue("Identifiant", genre.Identifiant);

            try
            {
                connection.Open();
                commande.ExecuteNonQuery();
                isDelete = true;
            }

            catch (Exception)
            {
                isDelete = false;
            }

            finally
            {
                connection.Close();
            }

            return isDelete;
        }
Exemplo n.º 13
0
 public Film(string name, Genre genre, int views, int price)
 {
     Name = name;
     FilmGenre = genre;
     Views = views;
     TicketPrice = price;
 }
Exemplo n.º 14
0
        public static Genre CreateGenre(Genre genre)
        {
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["EntretienSPPPConnectionString"];
            SqlConnection connection = new SqlConnection(connectionStringSettings.ToString());

            String requete = @"Insert INTO genre(libelle) Values (@libelle); SELECT SCOPE_IDENTITY() ; ";

            SqlCommand commande = new SqlCommand(requete, connection);

            commande.Parameters.AddWithValue("libelle",genre.libelle);

              try
            {
                connection.Open();
                Decimal IDENTIFIANTDERNIERAJOUT = (Decimal)commande.ExecuteScalar();
                return GenreDB.Get(Int32.Parse(IDENTIFIANTDERNIERAJOUT.ToString()));

            }

            catch (Exception)
            {
                throw;
            }

            finally
            {
                connection.Close();
            }
        }
Exemplo n.º 15
0
 public Author(string aFirstName, string aLastName, Genre aGenre)
     : this()
 {
     FirstName = aFirstName;
     LastName = aLastName;
     Genre = aGenre;
 }
Exemplo n.º 16
0
        private void addSongButton_Click(object sender, EventArgs e)
        {
            var repository = new CDCatalogRepository();
            var formHelper = new FormHelper();

            if (!formHelper.TextBoxHasContents(addSongTxtBoxSongGenre))
            {
                MessageBox.Show("Please enter a genre.", "Input validation error");
                addSongTxtBoxSongGenre.Focus();
            }
            else
            {
                var newGenre = addSongTxtBoxSongGenre.Text.Trim();
                var genres = repository.SearchGenreByGenreName(newGenre);

                if (genres.Count > 0)
                {
                    MessageBox.Show("You wanted to add " + newGenre + ", but " + genres[0].GenreName + " already exsists.", "Genre must be unique");
                    addSongTxtBoxSongGenre.Focus();
                }
                else
                {
                    CreatedGenre = repository.CreateGenre(addSongTxtBoxSongGenre.Text.Trim());
                    Close();
                }
            }
        }
Exemplo n.º 17
0
 public void OnRoomMusicChange(Genre roomGenre)
 {
     foreach (IMusicEventListener listener in IterateListeners<IMusicEventListener>())
     {
         listener.OnRoomMusicChange(roomGenre);
     }
 }
Exemplo n.º 18
0
        //
        // GET: /Store/Browse/

        public ActionResult Browse()
        {
            //return "Return from Store.Browse";

            /*
            String message = "Store.Browse, Genre = " +
                Server.HtmlEncode(Request.QueryString["Genre"]);
            return Server.HtmlEncode(message);
            //*/

            string genreName = Server.HtmlEncode(Request.QueryString["Genre"]);
            
            var genre = new Genre
            {
                Name = genreName,
            };

            var album = new List<Album>();

            album.Add(new Album { Title = genreName + "Album 1" });
            album.Add(new Album { Title = genreName + "Album 2" });
            album.Add(new Album { Title = genreName + "Album 3" });

            var viewModel = new StoreBrowseViewModel
            {
                genre = genre,
                albums = album
            };

            return View(viewModel);
            

        }
Exemplo n.º 19
0
 public StandardCombatInstance(ResourceAsset playerTeamPrefab, ResourceAsset enemyTeamPrefab, Genre combatGenre, int combatLevel)
 {
     m_playerTeamPrefab = playerTeamPrefab;
     m_enemyTeamPrefab = enemyTeamPrefab;
     m_combatGenre = combatGenre;
     m_combatLevel = combatLevel;
 }
Exemplo n.º 20
0
 public void AddGenre(GenreDto dto)
 {
     Genre entity = new Genre();
     entity.Name = dto.Name;
     _genreRepository.Add(entity);
     _genreRepository.Save();
 }
Exemplo n.º 21
0
        public IActionResult Create(
            string title,
            Genre genre,
            DateTime releaseDate,
            string description,
            decimal price,
            bool preorder)
        {
            var modifiedReleaseDate = releaseDate;
            if (releaseDate == null)
            {
                modifiedReleaseDate = DateTime.Today;
            }

            var movie = new Movie
            {
                Title = title,
                Genre = genre,
                ReleaseDate = modifiedReleaseDate,
                Description = description,
                Price = price,
                Preorder = preorder,
            };

            TryValidateModel(movie);
            if (ModelState.IsValid)
            {
                _context.AddMovie(movie);
                _context.SaveChanges();

                return RedirectToAction(actionName: nameof(Index));
            }

            return View(movie);
        }
Exemplo n.º 22
0
        // ReSharper disable once InconsistentNaming
        public void ShowsGenres_Is_Initialized()
        {
            var genre = new Genre();

            Assert.NotNull(genre.ShowsGenres);

            Assert.IsType<List<ShowsGenres>>(genre.ShowsGenres);
        }
Exemplo n.º 23
0
 public PageData(int pageLevel, Genre pageGenre, MoveType pageType, bool isRare)
 {
     m_pageLevel = pageLevel;
     m_pageGenre = pageGenre;
     m_pageType = pageType;
     m_isRare = isRare;
     m_inventoryId = -1;
 }
Exemplo n.º 24
0
        // ReSharper disable once InconsistentNaming
        public void Constructor_Task_Correct_Parameters()
        {
            var genre = new Genre();

            var showsGenres = new ShowsGenres(genre);

            Assert.Equal(genre, showsGenres.Genre);
        }
Exemplo n.º 25
0
 public void UpdateGenre(Genre genre)
 {
    using (var db = new DBConnection())
     {
         db.Entry(genre).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 public static void RemoveGenre(Groep g, Genre gr)
 {
     string sql = "DELETE FROM groep_genre WHERE GroepID = @GID and GenreID = @GrID";
     Database.ModifyData(sql,
         Database.AddParameter("@GID", g.ID),
         Database.AddParameter("@GrID", gr.ID)
         );
 }
 internal static void AddGenre(Genre genre, Groep groep)
 {
     string sql = "INSERT INTO groep_genre VALUES (@GID, @GrID)";
     Database.ModifyData(sql,
         Database.AddParameter("@GID", groep.ID),
         Database.AddParameter("@GrID", genre.ID)
         );
 }
Exemplo n.º 28
0
 public Video(int id, string title, Genre genres, TimeSpan runningTime, double rating)
 {
     Id = id;
      Title = title;
      Genres = genres;
      RunningTime = runningTime;
      Rating = rating;
 }
Exemplo n.º 29
0
        // ReSharper disable once InconsistentNaming
        public void Constructors_Accepts_The_Right_Parameters()
        {
            string name = "genre name";

            var genre = new Genre(name);

            Assert.Equal(name, genre.Name);
        }
Exemplo n.º 30
0
 public void CreateGenre(Genre genre)
 {
     using (var db = new DBConnection())
     {
         db.Genres.Add(genre);
         db.SaveChanges();
     }
 }
Exemplo n.º 31
0
        public async Task <IEnumerable <MovieResource> > GetMoviesByGenre2(Genre genre)
        {
            var movies = await GetMoviesByGenre(genre);

            return(ModelToResourceMapper.MapToMovieResource(movies));
        }
 public void AddGenre(Genre genre)
 {
     _context.Genre.Add(genre);
     _context.SaveChanges();
 }
Exemplo n.º 33
0
        public FB2UnionGenres()
        {
            const string xml = "union_genres_ru.xml";

            if (!File.Exists(xml))
            {
                string Message = string.Format("Не найден файл Жанров '{0}'.", xml);
                MessageBox.Show(Message);
                throw new Exception(Message);
            }

            XElement xmlTree = null;

            try {
                xmlTree = XElement.Load(xml);
            } catch {
                string Message = string.Format("Не могу прочитать файл Жанров  '{0}'.", xml);
                MessageBox.Show(Message);
                throw new Exception(Message);
            }

            if (xmlTree != null)
            {
                IEnumerable <XElement> Groups = xmlTree.Elements("group");
                foreach (XElement Group in Groups)
                {
                    string GroupName = Group.Attribute("name").Value;
                    IEnumerable <XElement> GenreList = Group.Elements("genre");
                    foreach (XElement Genre in GenreList)
                    {
                        _mdFB2GenresWithGroups.Add(
                            GroupName,
                            new KeyValuePair <string, string>(Genre.Attribute("name").Value, Genre.Attribute("code").Value)
                            );
                    }
                }
            }
        }
Exemplo n.º 34
0
 public DbEntityEntry Entry(Genre genre)
 {
     return(unitOfWork.Entry <Genre>(genre));
 }
Exemplo n.º 35
0
 public Book(string title, Author author, Genre genre)
 {
     Title  = title;
     Author = author;
     Genre  = genre;
 }
Exemplo n.º 36
0
        public GenreDTO GetByName(string genreName)
        {
            Genre genre = _database.GenreRepository.GetByName(genreName);

            return(_mapper.Map <Genre, GenreDTO>(genre));
        }
Exemplo n.º 37
0
 public static Views.Genres.Genre MapToView(this Genre model)
 {
     return(Mapper.Map <Views.Genres.Genre>(model));
 }
Exemplo n.º 38
0
        public ActionResult DisplaySearchResults(String SearchTitle, String SearchAuthor, int SelectedGenre, String UniqueNum, int SelectedFilter, Condition SelectedCondition)
        {
            var query = from c in _db.Books
                        select c;


            if (SearchTitle != null)
            {
                query = query.Where(c => c.Title.Contains(SearchTitle));
            }

            if (SearchAuthor != null)
            {
                query = query.Where(c => c.Author.Contains(SearchAuthor));
            }

            if (SelectedGenre != 0)
            {
                Genre GenreToDisplay = _db.Genres.Find(SelectedGenre);
                query = query.Where(c => c.Genre.GenreType.Contains(GenreToDisplay.GenreType));
            }

            if (UniqueNum != null && UniqueNum != "")
            {
                Int32 intUniqueNum;
                try
                {
                    intUniqueNum = Convert.ToInt32(UniqueNum);
                }
                catch
                {
                    ViewBag.Message   = UniqueNum + "is not valid number. Please try again";
                    ViewBag.AllGenres = GetAllGenres();

                    return(View("DetailedSearch"));
                }

                query = query.Where(c => c.UniqueID == intUniqueNum);
            }

            List <Book> BooksToDisplay = query.Include(c => c.Genre).Include(o => o.Reviews).Include(o => o.OrderDetails).ThenInclude(r => r.Order).ThenInclude(r => r.Coupon).ToList();

            ViewBag.TotalBooks    = _db.Books.Count();
            ViewBag.SelectedBooks = BooksToDisplay.Count();
            ViewBag.AllFilters    = GetAllFilters();

            switch (SelectedCondition)
            {
            case Condition.InStockOnly:
                query = query.Where(r => r.Availablity == "In stock");
                break;

            default:

                break;
            }

            if (SelectedFilter == 0)
            {
                return(View("Index", BooksToDisplay.OrderBy(b => b.Title)));
            }
            else if (SelectedFilter == 1)
            {
                return(View("Index", BooksToDisplay.OrderBy(b => b.Author)));
            }
            else if (SelectedFilter == 2)
            {
                return(View("Index", BooksToDisplay.OrderByDescending(b => b.OrderDetails.Sum(sum => sum.Quantity))));
            }
            else if (SelectedFilter == 3)
            {
                return(View("Index", BooksToDisplay.OrderByDescending(b => b.PublishedDate)));
            }
            else if (SelectedFilter == 4)
            {
                return(View("Index", BooksToDisplay.OrderBy(b => b.PublishedDate)));
            }
            else
            {
                return(View("Index", BooksToDisplay.OrderByDescending(b => b.AvgRating)));
            }
        }
Exemplo n.º 39
0
 public void MapToModel(Genre model)
 {
     model.Id          = this.Id;
     model.Name        = this.Name;
     model.Description = this.Description;
 }
 public async Task Delete(Genre genre)
 {
     _applicationContext.Genres.Remove(genre);
     await _applicationContext.SaveChangesAsync();
 }
Exemplo n.º 41
0
        public async Task SeedAsync(ApplicationDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (!dbContext.Genres.Any())
            {
                var genres = new Genre[]
                {
                    new Genre()
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Action",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Comedy",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Adventure",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Crime",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Drama",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Fantasy",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Historical",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Horror",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Romance",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Saga",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Satire",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Science fiction",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Thriller",
                    },

                    new Genre
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = "Animation",
                    },
                };
                foreach (var genre in genres)
                {
                    await dbContext.Genres.AddAsync(genre);
                }
            }
        }
Exemplo n.º 42
0
 protected virtual Task <IEnumerable <Movie> > GetMoviesByGenre(Genre genre)
 {
     return(_domainFacade.GetMoviesByGenre(genre));
 }
Exemplo n.º 43
0
        /// <summary>
        /// loads the information of a book from an online source
        /// </summary>
        public Book AutoLoadDNB(string isbn)
        {
            Book book = new Book();

            book.BookIsbn = isbn;
            if (IsbnValidated(isbn))
            {
                htmlData = Regex.Replace(htmlData, @"\t|\n|\r", "");
                htmlData = Regex.Replace(htmlData, "<a href=.*?>", "");
                var genreName = GetGenreNeu().Replace("[", "(").Replace("]", ")");
                if (!genreName.Equals(""))
                {
                    GenreHelper helper = new GenreHelper();
                    Genre       genre  = new Genre();
                    if (helper.FindIdByName(genreName) < 0)
                    {
                        genre.GenreName = genreName;
                        genre.Add();
                    }
                    genre          = new Genre(helper.FindIdByName(genreName));
                    book.BookGenre = genre;
                }

                var titel = GetTitelNeu().Replace("[", "(").Replace("]", ")");
                if (!titel.Equals(""))
                {
                    book.BookTitle = titel;
                }

                var authors = GetAutorNeu();
                foreach (string s in authors)
                {
                    Author       author = new Author();
                    AuthorHelper helper = new AuthorHelper();
                    if (helper.FindIdByName(s) < 0)
                    {
                        author.AuthorName = s;
                        author.Add();
                    }
                    author = new Author(helper.FindIdByName(s));
                    book.BookAuthors.Add(author);
                }

                var ausgabe = GetAusgabeNeu().Replace("[", "(").Replace("]", ")");
                if (!ausgabe.Equals(""))
                {
                    book.BookEdition = ausgabe;
                }

                var publisherName = GetVerlagNeu().Replace("[", "(").Replace("]", ")");
                if (!publisherName.Equals(""))
                {
                    PublisherHelper helper    = new PublisherHelper();
                    Publisher       publisher = new Publisher();
                    if (helper.FindIdByName(publisherName) < 0)
                    {
                        publisher.PublisherName = publisherName;
                        publisher.Add();
                    }
                    publisher          = new Publisher(helper.FindIdByName(publisherName));
                    book.BookPublisher = publisher;
                }

                var jahr = GetDatumNeu();
                if (!jahr.Equals(""))
                {
                    try
                    {
                        DateTime date = new DateTime(int.Parse(jahr), 1, 1);
                        book.BookDatePublication = date;
                    }
                    catch
                    {
                        book.BookDatePublication = DateTime.UtcNow;
                    }
                }

                var preis = GetPreisNeu().Replace('.', ',');
                if (!preis.Equals(""))
                {
                    book.BookPrice = decimal.Parse(preis);
                }

                var languageName = GetSpracheNeu().Replace("[", "(").Replace("]", ")");
                if (!languageName.Equals(""))
                {
                    LanguageHelper helper   = new LanguageHelper();
                    Language       language = new Language();
                    if (helper.FindIdByName(languageName) < 0)
                    {
                        language.LanguageName = languageName;
                        language.Add();
                    }
                    language          = new Language(helper.FindIdByName(languageName));
                    book.BookLanguage = language;
                }

                var image = GetPictureNeu(isbn);
                if (image != null)
                {
                    book.BookImage = image;
                }
                return(book);
                //MetroMessageBox.Show(this, "Das Buch \"" + tb_Titel.Text + "\" wurde erfolgreich geladen!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                return(book);
                //AutoLoadBuecherNachISBN();
            }
        }
Exemplo n.º 44
0
        public ActionResult Create()
        {
            Genre newGenre = new Genre();

            return(View("GenreForm", newGenre));
        }
Exemplo n.º 45
0
 public Song(string title, int length, Genre genre)
 {
     Title  = title;
     Length = length;
     Genre  = genre;
 }
 public void DeleteGenre(Genre genre)
 {
     _context.Genre.Remove(genre);
     _context.SaveChanges();
 }
Exemplo n.º 47
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["home.cshtml"]);
            };
//VENUES PATHING
            Get["/venues"] = _ => {
                List <Venue> allVenues = Venue.GetAll();
                return(View["venues_home.cshtml", allVenues]);
            };
            Get["/venues/add"] = _ => {
                return(View["venue_add_form.cshtml"]);
            };
            Post["/venues/add"] = _ => {
                string testIfNameEmpty = Request.Form["venue-name"];
                string testIfCityEmpty = Request.Form["venue-city"];
                if ((testIfNameEmpty != "") && (testIfCityEmpty != ""))
                {
                    Venue newVenue = new Venue(Request.Form["venue-name"], Request.Form["venue-city"]);
                    newVenue.Save();
                    return(View["success.cshtml"]);
                }
                else
                {
                    return(View["dun_goofed.cshtml"]);
                }
            };
            Get["/venues/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var selectedVenue = Venue.Find(parameters.id);
                var venuesBands   = selectedVenue.GetBands();
                var allBands      = Band.GetAll();
                model.Add("venue", selectedVenue);
                model.Add("bands", venuesBands);
                model.Add("allBands", allBands);
                return(View["venue.cshtml", model]);
            };
            Post["/venues/{id}/edit_band"] = _ => {
                Venue selectedVenue = Venue.Find(Request.Form["venue-id"]);
                Band  selectedBand  = Band.Find(Request.Form["band-id"]);
                selectedVenue.AddBandToShowsJoinTable(selectedBand);
                return(View["success.cshtml"]);
            };
            Patch["/venues/{id}/edit"] = parameters => {
                Venue  selectedVenue = Venue.Find(parameters.id);
                string newName       = Request.Form["venue-name"];
                string newCity       = Request.Form["venue-city"];
                if (newName != "")
                {
                    selectedVenue.UpdateName(newName);
                }
                if (newCity != "")
                {
                    selectedVenue.UpdateCity(newCity);
                }
                if (newName == "" && newCity == "")
                {
                    return(View["dun_goofed.cshtml"]);
                }
                return(View["success.cshtml"]);
            };
            Delete["/venues/{id}/delete"] = _ => {
                Venue selectedVenue = Venue.Find(Request.Form["venue-id"]);
                selectedVenue.Delete();
                return(View["success.cshtml"]);
            };
//BANDS PATHING
            Get["/bands"] = _ => {
                List <Band> allBands = Band.GetAll();
                return(View["bands_home.cshtml", allBands]);
            };
            Get["/bands/add"] = _ => {
                return(View["band_add_form.cshtml"]);
            };
            Post["/bands/add"] = _ => {
                string testIfNameEmpty = Request.Form["band-name"];
                if (testIfNameEmpty != "")
                {
                    Band newBand = new Band(Request.Form["band-name"]);
                    newBand.Save();
                    return(View["success.cshtml"]);
                }
                else
                {
                    return(View["dun_goofed.cshtml"]);
                }
            };
            Get["/bands/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var selectedBand = Band.Find(parameters.id);
                var bandsVenues  = selectedBand.GetVenues();
                var bandsGenres  = selectedBand.GetGenres();
                var allVenues    = Venue.GetAll();
                model.Add("band", selectedBand);
                model.Add("venues", bandsVenues);
                model.Add("allVenues", allVenues);
                model.Add("genres", bandsGenres);
                return(View["band.cshtml", model]);
            };
            Post["/bands/{id}/edit_venue"] = _ => {
                Band  selectedBand  = Band.Find(Request.Form["band-id"]);
                Venue selectedVenue = Venue.Find(Request.Form["venue-id"]);
                selectedBand.AddVenueToShowsJoinTable(selectedVenue);
                return(View["success.cshtml"]);
            };
//GENRE PATHING
            Get["/genres"] = _ => {
                List <Genre> allGenres = Genre.GetAll();
                return(View["genres_home.cshtml", allGenres]);
            };
            Get["/genres/add"] = _ => {
                return(View["genre_add_form.cshtml"]);
            };
            Post["/genres/add"] = _ => {
                string testIfNameEmpty = Request.Form["genre-name"];
                if (testIfNameEmpty != "")
                {
                    Genre newGenre = new Genre(Request.Form["genre-name"]);
                    newGenre.Save();
                    return(View["success.cshtml"]);
                }
                else
                {
                    return(View["dun_goofed.cshtml"]);
                }
            };
            Get["/genres/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var selectedGenre = Genre.Find(parameters.id);
                var genresBands   = selectedGenre.GetBands();
                var allBands      = Band.GetAll();
                model.Add("genre", selectedGenre);
                model.Add("bands", genresBands);
                model.Add("allBands", allBands);
                return(View["genre.cshtml", model]);
            };
            Patch["/genres/{id}/edit_name"] = parameters => {
                Genre  selectedGenre   = Genre.Find(parameters.id);
                string testIfNameEmpty = Request.Form["genre-name"];
                if (testIfNameEmpty != "")
                {
                    selectedGenre.UpdateName(testIfNameEmpty);
                    return(View["success.cshtml"]);
                }
                else
                {
                    return(View["dun_goofed.cshtml"]);
                }
            };
            Post["/genres/{id}/edit_band"] = _ => {
                Genre selectedGenre = Genre.Find(Request.Form["genre-id"]);
                Band  selectedBand  = Band.Find(Request.Form["band-id"]);
                selectedGenre.AddBandToBands_GenresJoinTable(selectedBand);
                return(View["success.cshtml"]);
            };
        }
Exemplo n.º 48
0
 public async Task UpdateGenre(Genre genre)
 {
     context.Attach(genre).State = EntityState.Modified;
     await context.SaveChangesAsync();
 }
 public void UpdateGenre(Genre genre)
 {
     _context.Genre.Update(genre);
     _context.SaveChanges();
 }
Exemplo n.º 50
0
        public IActionResult Index(MusicFileCreateViewModel model)
        {
            if (ModelState.IsValid && model.Files != null)
            {
                foreach (var file in model.Files)
                {
                    // The files must be uploaded to their respective folder in wwwroot
                    string songsFolder    = Path.Combine(_webHostEnvironment.WebRootPath, "songs");
                    string albumArtFolder = Path.Combine(_webHostEnvironment.WebRootPath, "images");

                    // A new GUID value ensures a unique file name
                    string songFileName = Guid.NewGuid().ToString() + ".mp3";
                    string songFilePath = Path.Combine(songsFolder, songFileName);

                    // Copy the file to the wwwroot/songs folder
                    // Using block automatically disposes the file stream at the end
                    using (FileStream fileStream = new FileStream(songFilePath, FileMode.Create))
                    {
                        file.CopyTo(fileStream);
                    }

                    // Open the file using TagLib-Sharp
                    var tagLibFile = TagLib.File.Create(songFilePath);

                    string albumArtFileName = null;

                    if (tagLibFile.Tag.Pictures.Length >= 1)
                    {
                        string imageType = tagLibFile.Tag.Pictures[0].MimeType.Split("/").Last();

                        // A new GUID value ensures a unique file name
                        albumArtFileName = Guid.NewGuid().ToString() + "." + imageType;
                        string albumArtFilePath = Path.Combine(albumArtFolder, albumArtFileName);

                        // Copy the album art to the wwwroot/images folder
                        using (FileStream fileStream = new FileStream(albumArtFilePath, FileMode.Create))
                        {
                            fileStream.Write(tagLibFile.Tag.Pictures[0].Data.Data);
                        }
                    }

                    Genre genre = Genre.NONE;

                    try
                    {
                        genre = (Genre)Enum.Parse(typeof(Genre), tagLibFile.Tag.FirstGenre, true);
                    }
                    catch (Exception)
                    {
                        // Genre will default to NONE if no match is found
                    }

                    MusicFile musicFile = new MusicFile
                    {
                        FilePath     = songFileName,
                        IsChecked    = false,
                        AlbumArtPath = albumArtFileName,
                        FileName     = file.FileName,
                        Title        = tagLibFile.Tag.Title,
                        Artist       = tagLibFile.Tag.FirstPerformer,
                        Genre        = genre
                    };

                    _musicFileRepository.Add(musicFile);
                }
            }

            MusicFileCreateViewModel musicFileCreateViewModel = new MusicFileCreateViewModel
            {
                Genres     = EnumHelper <Genre> .GetDisplayValues(Genre.NONE),
                MusicFiles = _musicFileRepository.GetAllMusicFiles()
            };

            return(View(musicFileCreateViewModel));
        }
        public List <vmMusiciansInstrumentsByGenre> Get(int id)
        {
            if (id != 0)
            {
                Genre GG = new Genre();
                List <MusicianGenre> MGs = new List <MusicianGenre>();
                List <vmMusiciansInstrumentsByGenre> vmMIGs = new List <vmMusiciansInstrumentsByGenre>();

                GG  = repo.Query <Genre>().Where(a => a.GenreId == id).FirstOrDefault();
                MGs = repo.Query <MusicianGenre>().Where(b => b.GenreId == id).ToList();
                foreach (MusicianGenre MG in MGs)
                {
                    List <Musician> MMs = new List <Musician>();
                    MMs = repo.Query <Musician>().Where(c => c.MusicianId == MG.MusicianId).ToList();
                    foreach (Musician MM in MMs)
                    {
                        UserMusician UM = new UserMusician();
                        UM = repo.Query <UserMusician>().Where(d => d.MusicianId == MM.MusicianId).FirstOrDefault();
                        AppUser AU = new AppUser();
                        AU = repo.Query <AppUser>().Where(e => e.AppUserId == UM.AppUserId).FirstOrDefault();


                        List <MusicianInstrument> MIs = new List <MusicianInstrument>();
                        MIs = repo.Query <MusicianInstrument>().Where(f => f.MusicianId == MM.MusicianId).ToList();
                        List <vmInstrument> vmInsts = new List <vmInstrument>();
                        foreach (MusicianInstrument MI in MIs)
                        {
                            Instrument Inst = new Instrument();
                            Inst = repo.Query <Instrument>().Where(g => g.InstrumentId == MI.InstrumentId).FirstOrDefault();
                            vmInstrument vmInst = new vmInstrument
                            {
                                InstrumentId   = Inst.InstrumentId,
                                InstrumentName = Inst.InstrumentName
                            };
                            vmInsts.Add(vmInst);
                        }
                        ;
                        vmMusiciansInstrumentsByGenre vmMIG = new vmMusiciansInstrumentsByGenre
                        {
                            GenreId           = GG.GenreId,
                            GenreName         = GG.GenreName,
                            AppUserId         = AU.AppUserId,
                            LastName          = AU.LastName,
                            FirstName         = AU.FirstName,
                            IsMusician        = AU.IsMusician,
                            MusicianId        = MM.MusicianId,
                            StageName         = MM.StageName,
                            IsMusicianForHire = MM.IsMusicianForHire,
                            vmInstruments     = vmInsts
                        };
                        vmMIGs.Add(vmMIG);
                    }
                    ;
                }
                ;
                return(vmMIGs);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 52
0
 public void Update(Genre genre)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 53
0
        public void Equals_Reflexive_Success()
        {
            Genre genre = CreateDefaultGenre();

            Assert.True(genre.Equals(genre));
        }
Exemplo n.º 54
0
 public DVD(string Title, int RunTime, Genre Category, List <string> Scenes)
     : base(Title, RunTime, Category, Scenes)
 {
 }
Exemplo n.º 55
0
 public async Task CreateGenre(Genre genre)
 {
     context.Add(genre);
     await context.SaveChangesAsync();
 }
Exemplo n.º 56
0
        private void exec_btn_Click(object sender, RoutedEventArgs e)
        {
            if (mode.Equals("Add"))
            {
                // Если мы оставили все поля пустыми:
                if (name_txt.Text == "")
                {
                    MessageBox.Show("Вы оставили все поля пустыми", "Все поля пустые...", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                // Если мы оставили все поля пустыми:
                else if (name_txt.Text == "")
                {
                    MessageBox.Show("Какое то пеле оставили пустым", "Пустое к-ето поле...", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    try
                    {
                        Genre g = new Genre
                        {
                            Id   = autoIncrement,
                            Name = name_txt.Text
                        };

                        // Add to Books table of databese:
                        string msg = InsertToDatabase.InsertGenre(g);
                        MessageBox.Show(msg, "Added");

                        (this.Owner as MainWindow).listBox1.Items.Add(g);
                        (this.Owner as MainWindow).listBox1.Items.Clear();

                        genres = ReadFromDatabase.ReadAllGenres().ToArray();

                        // Ubdate listbox to curent datas from a table Books:
                        foreach (Genre gg in genres)
                        {
                            (this.Owner as MainWindow).listBox1.Items.Add(gg);
                        }
                        ClearFields();
                        this.Close();
                    }
                    catch { MessageBox.Show("Вы ввели символи, или строку вместо целого числа", "Не правильный формат", MessageBoxButton.OK, MessageBoxImage.Warning); }
                }
            }
            else if (mode.Equals("Update"))
            {
                // Если мы оставили все поля пустыми:
                if (name_txt.Text == "")
                {
                    MessageBox.Show("Вы оставили все поля пустыми", "Все поля пустые...", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                // Если мы оставили все поля пустыми:
                else if (name_txt.Text == "")
                {
                    MessageBox.Show("Какое то пеле оставили пустым", "Пустое к-ето поле...", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    try
                    {
                        My_Context db    = new My_Context();
                        int        index = (this.Owner as MainWindow).listBox1.Items.IndexOf(this.genre);

                        // Get Id entity from the Table:
                        int id = genre.Id;

                        // Get entity from DbSet to Id and edit it:
                        List <Genre> all     = ReadFromDatabase.ReadAllGenres();
                        Genre        updated = all.Where(u => u.Id == id).FirstOrDefault();
                        //updated.Id = index + 1;
                        updated.Name = name_txt.Text;

                        // Update to Database:
                        db.Entry(updated).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        //MessageBox.Show(msg, "Updated");

                        (this.Owner as MainWindow).listBox1.Items.RemoveAt(index);
                        (this.Owner as MainWindow).listBox1.Items.Insert(index, updated);
                        (this.Owner as MainWindow).listBox1.Items.Clear();

                        genres = ReadFromDatabase.ReadAllGenres().ToArray();
                        foreach (Genre b in genres)
                        {
                            (this.Owner as MainWindow).listBox1.Items.Add(b);
                        }
                        this.Close();
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message, "System Exception..Failed..", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Incorrect sting parameter 'mode'..", "Something went wrong...", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemplo n.º 57
0
        public async Task <GenreDTO> Delete(string id)
        {
            Genre genre = await _database.GenreRepository.Delete(id);

            return(_mapper.Map <Genre, GenreDTO>(genre));
        }
 public Genre MapDTOToGenre(GenreDTO genreDTO, Genre genre)
 {
     genre.Name = genreDTO.Name;
     return(genre);
 }
Exemplo n.º 59
0
 public GenreViewModel(Genre model)
 {
     this.Id          = model.Id;
     this.Name        = model.Name;
     this.Description = model.Description;
 }
Exemplo n.º 60
0
        public async Task <GenreDTO> Update(GenreDTO item)
        {
            Genre genre = await _database.GenreRepository.Update(_mapper.Map <GenreDTO, Genre>(item));

            return(_mapper.Map <Genre, GenreDTO>(genre));
        }