public ActionResult Add(int id, EventBindingModel model) { if (!ModelState.IsValid) { return this.View(model); } var genreInModel = this.genres.All() .Where(g => g.Genre == model.Genre) .FirstOrDefault(); if (genreInModel == null) { genreInModel = new MusicGenre() { Genre = model.Genre }; this.genres.Add(genreInModel); } Image image = null; if (model.Image != null) { using (var memory = new MemoryStream()) { model.Image.InputStream.CopyTo(memory); var contentAsArray = memory.GetBuffer(); image = new Image { Content = contentAsArray }; } } this.images.Add(image); var club = this.clubs.GetById(id); var evnt = new Event() { Club = club, Title = model.Title, Description = model.Description, StartsAt = model.StartsAt, EventOwner = model.EventOwner, EntranceFee = model.EntranceFee, MusicGenre = genreInModel, Url = model.Url, Image = image }; this.events.Add(evnt); this.events.SaveChanges(); this.TempData["Notification"] = "Event added successfully!"; return this.RedirectToAction("Index", "Home"); }
/////////////////////////////////////////// public ActionResult AddGenre() { MusicGenre musicgenre = new MusicGenre(); return(View(musicgenre)); }
// Read-Only Indexer - return a collection of music files for genre public IEnumerable <MusicFile> this[MusicGenre genre] { get { // LINQ var tracksForGenre = tracks.Where(t => t.Genre == genre); return(tracksForGenre); } }
/// <summary> /// Creates a party object for the api/party post endpoint. /// </summary> private dynamic CreatePartyCreateObject(string name, DateTime date, MusicGenre genre, string country, string cityName, string street, string houseNr, string zipcode, PartyType type, string description , int price) { dynamic partyCreationObject = new ExpandoObject(); partyCreationObject.partyName = name; partyCreationObject.partyDate = date; partyCreationObject.musicGenre = (int)genre; partyCreationObject.countryName = country; partyCreationObject.cityName = cityName; partyCreationObject.streetName = street; partyCreationObject.houseNumber = houseNr; partyCreationObject.zipcode = zipcode; partyCreationObject.partyType = (int)type; partyCreationObject.description = description; partyCreationObject.price = price; return(partyCreationObject); }
public static string GenreToString(MusicGenre genre) { switch (genre) { case MusicGenre.CLASSIC: return("Инструментальная"); case MusicGenre.FOLK: return("Фолк"); case MusicGenre.INDI: return("Инди"); case MusicGenre.JAZZ: return("Джаз"); case MusicGenre.POP: return("Поп"); case MusicGenre.ROCK: return("Рок"); case MusicGenre.RAP: return("Реп"); default: return(""); } }
public void InitAlbum(Album album) { Id = album.Id; Name = album.Name; Artist = album.Artist; FileName = album.FileName; MusicGenre = album.MusicGenre; }
public ActionResult DeleteConfirmed(int id) { MusicGenre musicGenre = db.MusicGenre.Find(id); db.MusicGenre.Remove(musicGenre); db.SaveChanges(); return(RedirectToAction("Index")); }
// indexer - return a collection of music files for specified genre public IEnumerable <MusicFile> this[MusicGenre genre] { get { var tracksForGenre = tracks.Where(t => t.Genre == genre); // LINQ query, select the whole music file return(tracksForGenre); } }
public void InitTrack(Track track) { Id = track.Id; Name = track.Name; Artist = track.Artist; FileName = track.FileName; AlbumId = track.AlbumId; MusicGenre = track.MusicGenre; }
public ActionResult Edit([Bind(Include = "MusicGenreId,GenreType")] MusicGenre musicGenre) { if (ModelState.IsValid) { db.Entry(musicGenre).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(musicGenre)); }
private void SongEditorForm_Load(object sender, EventArgs e) { if (song != null) { SongTitle = song.Title; SongAuthor = song.Author; SongRelease = song.Release; SongGenre = song.Genre; MusicGenreControl1_GenreChanged(SongGenre); } }
public ActionResult Create([Bind(Include = "MusicGenreId,GenreType")] MusicGenre musicGenre) { if (ModelState.IsValid) { db.MusicGenre.Add(musicGenre); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(musicGenre)); }
public Person(long id, string firstName, string lastName, byte age, MusicGenre genere) { Id = id; FirstName = firstName; LastName = lastName; Age = age; FavoriteMusicType = genere; FavoriteSongs = new List<Song> (); }
public ActionResult AddGenre(MusicGenre musicgenre) { if (ModelState.IsValid) { repository.AddMusicGenre(musicgenre); return(RedirectToAction("Index", "Home", null)); } else { return(View(musicgenre)); } }
public void AddAlbum(string artist, string title, MusicGenre genre, string coverArt) { Album album = new Album() { Artist = artist, Title = title, Genre = genre, CoverArt = coverArt }; Context.Albums.Add(album); Context.SaveChanges(); }
// GET: MusicGenre/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MusicGenre musicGenre = db.MusicGenre.Find(id); if (musicGenre == null) { return(HttpNotFound()); } return(View(musicGenre)); }
public void AddTrack(string artist, string title, MusicGenre genre, string link, decimal price) { Track track = new Track() { Artist = artist, Title = title, Genre = genre, Link = link, Price = price }; Context.Tracks.Add(track); Context.SaveChanges(); }
private Bitmap GetMusicGenreImage(MusicGenre genre) { switch (genre) { case MusicGenre.POP: return(Properties.Resources.popIcon); case MusicGenre.ROCK: return(Properties.Resources.rockIcon); case MusicGenre.RAP: return(Properties.Resources.rapIcon); } return(null); }
// validate that title and artist are not blank public MusicFile(String filename, String title, String artist, MusicGenre genre) : base(filename) { if (String.IsNullOrEmpty(title)) { throw new ArgumentException("title must not be null or empty"); } else if (String.IsNullOrEmpty(artist)) { throw new ArgumentException("artist must not be null or empty"); } // set fields this.title = title; this.artist = artist; this.genre = genre; }
private async Task AddMusicGenreRecordAsync(int musicId, string genreName) { var musicgenreList = await unitOfWork.MusicGenreRepository.GetByMusicId(musicId); foreach (var musicGenre in musicgenreList) { await unitOfWork.MusicGenreRepository.Delete(musicGenre); } var genre = await unitOfWork.GenreRepository.GetByName(genreName); var mg = new MusicGenre { MusicId = musicId, GenreId = genre.Id, }; await unitOfWork.MusicGenreRepository.Add(mg); }
public MusicFile(String fileName, String title, String artist, MusicGenre genre) : base(fileName) { if (String.IsNullOrEmpty(title)) { throw new ArgumentException("Title cannot be empty"); } else if (String.IsNullOrEmpty(artist)) { throw new ArgumentException("Artist cannot be empty"); } else { this.title = title; this.artist = artist; this.genre = genre; } }
public async Task <Result <Party> > CreateParty(string name, DateTime date, MusicGenre genre, string country, string cityName, string street, string houseNr, string zipcode, PartyType type, string description, int price) { //Create an object from the given parameters for the party creation dynamic partyCreationObject = CreatePartyCreateObject(name, date, genre, country, cityName, street, houseNr, zipcode, type, description, price); //Send the create party request Result <Guid> result = await _clientService.SendRequest <Guid>("api/party", RestType.Post, bodyParameter : partyCreationObject, token : Token.AccessToken); Result <Party> partyResult = new Result <Party> { IsCached = result.IsCached, Message = result.Message, RequestFailedToException = result.RequestFailedToException, StatusCode = result.StatusCode, Success = result.Success }; if (result.Success) { //Accept to the party, as host you obviously appear. await ChangeCommitmentState(result.Data, PartyCommitmentState.Accepted); DebugHelper.PrintDebug(DebugType.Info, $"Guid of the created party is {result.Data}"); //Get the created party if the creation was successfull. partyResult = await GetParty(result.Data); } //Return the created party return(partyResult); }
private MusicGenre NextMusicGenre(MusicGenre genre) { return((MusicGenre)(((int)genre + 1) % 3)); }
private void MusicGenreControl_Click(object sender, EventArgs e) { ChosenGenre = NextMusicGenre(); GenreChanged?.Invoke(ChosenGenre); Invalidate(); }
public MusicGenreControl() { ChosenGenre = MusicGenre.POP; InitializeComponent(); }
public void Add(MusicGenre genre) { this.genres.Add(genre); this.genres.SaveChanges(); }
public ActionResult Add(int id, EventBindingModel model) { if (!ModelState.IsValid) { return(this.View(model)); } var genreInModel = this.genres.All() .Where(g => g.Genre == model.Genre) .FirstOrDefault(); if (genreInModel == null) { genreInModel = new MusicGenre() { Genre = model.Genre }; this.genres.Add(genreInModel); } Image image = null; if (model.Image != null) { using (var memory = new MemoryStream()) { model.Image.InputStream.CopyTo(memory); var contentAsArray = memory.GetBuffer(); image = new Image { Content = contentAsArray }; } } this.images.Add(image); var club = this.clubs.GetById(id); var evnt = new Event() { Club = club, Title = model.Title, Description = model.Description, StartsAt = model.StartsAt, EventOwner = model.EventOwner, EntranceFee = model.EntranceFee, MusicGenre = genreInModel, Url = model.Url, Image = image }; this.events.Add(evnt); this.events.SaveChanges(); this.TempData["Notification"] = "Event added successfully!"; return(this.RedirectToAction("Index", "Home")); }
public ActionResult Add(ClubBindingViewModel model) { if (!this.ModelState.IsValid) { return this.View(model); } var user = this.users.GetAll() .Where(u => u.UserName == this.User.Identity.Name) .FirstOrDefault(); Image image = null; if (model.ProfilePic != null) { using (var memory = new MemoryStream()) { model.ProfilePic.InputStream.CopyTo(memory); var contentAsArray = memory.GetBuffer(); image = new Image { Content = contentAsArray }; } } this.images.Add(image); var genreInModel = this.genres.GetAll() .Where(g => g.Genre == model.Genre) .FirstOrDefault(); if (genreInModel == null) { genreInModel = new MusicGenre() { Genre = model.Genre }; this.genres.Add(genreInModel); } var clubToAdd = new Club() { Moderator = user, Name = model.Name, Adress = model.Adress, Phone = model.Phone, SiteUrl = model.SiteUrl, FacebookUrl = model.FacebookUrl, TwitterUrl = model.TwitterUrl, Email = model.Email, Capacity = model.Capacity, MusicGenre = genreInModel, ProfilePic = image }; this.clubs.Add(clubToAdd); this.TempData["Notification"] = "Club created successfully!"; return this.RedirectToAction("Index", "Home"); // change later to browse action }
protected override void Seed(ApplicationDbContext context) { if (!context.Roles.Any()) { var roleStore = new RoleStore <IdentityRole>(context); var roleManager = new RoleManager <IdentityRole>(roleStore); // Create Admin role var adminRole = new IdentityRole { Name = GlobalConstants.AdministratorRoleName }; roleManager.Create(adminRole); // Create User role var userRole = new IdentityRole { Name = GlobalConstants.UserRoleName }; roleManager.Create(userRole); // Create admin user var userStore = new UserStore <User>(context); var userManager = new UserManager <User>(userStore); var admin = new User { FirstName = GlobalConstants.AdministratorFirstName, LastName = GlobalConstants.AdministratorLastName, UserName = GlobalConstants.AdministratorUserName, Email = GlobalConstants.AdministratorUserName }; userManager.Create(admin, GlobalConstants.AdministratorPassword); // Assign user to admin role userManager.AddToRole(admin.Id, GlobalConstants.AdministratorRoleName); // Add TelerikAcademy for Demo Purposes var location = new Location() { Longitude = 23.3772423, Latitude = 42.6508509 }; var locations = new DeletableEntityRepository <Location>(context); locations.Add(location); locations.SaveChanges(); byte[] img1; byte[] img2; using (var webClient = new WebClient()) { img1 = webClient.DownloadData("http://telerikacademy.com/Content/Images/news-img01.png"); img2 = webClient.DownloadData("http://yaltaclub.com/images/yalta-logo.png?1383083648"); } var club1Image = new Image { Content = img1 }; var images = new DeletableEntityRepository <Image>(context); images.Add(club1Image); var genres = new DeletableEntityRepository <MusicGenre>(context); var dance = new MusicGenre { Genre = Models.Enums.MusicGenreEnum.Dance }; var house = new MusicGenre { Genre = Models.Enums.MusicGenreEnum.House }; genres.Add(dance); genres.Add(house); var club = new Club() { ProfilePic = club1Image, Name = "TelerikAcademy", Adress = @"бул. ""Александър Малинов"" 31, 1729 София", Phone = "02 809 9897", Location = location, SiteUrl = "http://academy.telerik.com/", FacebookUrl = "https://www.facebook.com/TelerikAcademy", TwitterUrl = "https://twitter.com/TelerikAcademy", Email = "*****@*****.**", Capacity = 2000, ModeratorId = admin.Id, MusicGenre = dance }; var review = new ClubReview() { Club = club, Content = "TEST TEST TEST TEST", Rating = 5, Author = admin }; var reviews = new DeletableEntityRepository <ClubReview>(context); reviews.Add(review); var clubs = new DeletableEntityRepository <Club>(context); clubs.Add(club); var club2Image = new Image { Content = img2 }; images.Add(club2Image); var club2 = new Club() { ProfilePic = club2Image, Name = "Yalta Club", Adress = @"20, Tsar Osvoboditel Blvd, Sofia 1000, Bulgaria", Phone = "0897 870 230", Location = location, SiteUrl = "http://yaltaclub.com/", FacebookUrl = "https://www.facebook.com/yaltaclub", TwitterUrl = string.Empty, Email = "*****@*****.**", Capacity = 4000, ModeratorId = admin.Id, MusicGenre = house }; var review2 = new ClubReview() { Club = club2, Content = "TE ST TE ST TE ST", Author = admin, Rating = 4 }; reviews.Add(review2); clubs.Add(club2); clubs.SaveChanges(); } }
public void ModifySong(Song songToModify, string title, string author, DateTime release, MusicGenre genre) { songToModify.Title = title; songToModify.Author = author; songToModify.Release = release; songToModify.Genre = genre; SongModified?.Invoke(songToModify); }
public static void ShowGenre(object sender, ShowPageEventArgs e) { e.Template.SetTemplate("Musician", "music_directory_genres"); string genre = e.Core.PagePathParts[1].Value; MusicGenre genreObject = null; try { genreObject = new MusicGenre(e.Core, genre); } catch (InvalidMusicGenreException) { e.Core.Functions.Generate404(); return; } VariableCollection genreVariableCollection = e.Template.CreateChild("genre_list"); genreVariableCollection.Parse("U_GENRE", genreObject.Uri); genreVariableCollection.Parse("DISPLAY_NAME", genreObject.Name); genreVariableCollection.Parse("MUSICIANS", e.Core.Functions.LargeIntegerToString(genreObject.Musicians)); if (genreObject.ParentId == 0) { List<MusicGenre> subGenres = genreObject.GetSubGenres(); foreach (MusicGenre subGenre in subGenres) { VariableCollection subGenreVariableCollection = genreVariableCollection.CreateChild("subgenre_list"); subGenreVariableCollection.Parse("U_SUBGENRE", subGenre.Uri); subGenreVariableCollection.Parse("DISPLAY_NAME", subGenre.Name); subGenreVariableCollection.Parse("MUSICIANS", e.Core.Functions.LargeIntegerToString(subGenre.Musicians)); } } List<Musician> musicians = genreObject.GetMusicians(e.Core.Functions.GetFilter(), e.Page.TopLevelPageNumber); // TODO: cache long musicianCount = musicians.Count; // e.Db.LastQueryRows; Dictionary<long, MusicGenre> musicianGenres = MusicGenre.GetGenres(e.Core, musicians); foreach (Musician musician in musicians) { VariableCollection musicianVariableCollection = e.Template.CreateChild("musicians_list"); musicianVariableCollection.Parse("U_MUSICIAN", musician.Uri); musicianVariableCollection.Parse("DISPLAY_NAME", musician.DisplayName); musicianVariableCollection.Parse("I_TILE", musician.Tile); musicianVariableCollection.Parse("I_ICON", musician.Icon); if (musician.GenreRaw > 0 && musicianGenres.ContainsKey(musician.GenreRaw)) { musicianVariableCollection.Parse("GENRE", musicianGenres[musician.GenreRaw].Name); } if (musician.SubGenreRaw > 0 && musicianGenres.ContainsKey(musician.SubGenreRaw)) { musicianVariableCollection.Parse("SUB_GENRE", musicianGenres[musician.SubGenreRaw].Name); } } e.Template.Parse("ARTISTS", musicianCount.ToString()); e.Core.Display.ParsePagination(GetDirectoryUri(e.Core, e.Core.Functions.GetFilter(), genreObject.Slug), e.Page.TopLevelPageNumber, (int)(Math.Ceiling(musicianCount / 10.0))); }
public static List<Musician> GetMusicians(Core core, string firstLetter, MusicGenre genre, int page) { List<Musician> musicians = new List<Musician>(); SelectQuery query = Musician.GetSelectQueryStub(core, typeof(Musician)); if (genre != null) { if (genre.IsSubGenre) { query.AddCondition("musician_genre", genre.Id); } else { query.AddCondition("musician_genre", genre.Id); } } if (!string.IsNullOrEmpty(firstLetter)) { query.AddCondition("musician_name_first", firstLetter); } if (page >= -1) { query.LimitCount = 10; query.LimitStart = Functions.LimitPageToStart(page, 10); } query.AddSort(SortOrder.Ascending, "musician_slug"); DataTable musiciansTable = core.Db.Query(query); foreach (DataRow dr in musiciansTable.Rows) { musicians.Add(new Musician(core, dr, MusicianLoadOptions.Common)); } return musicians; }
public Song(string title, int lenght, MusicGenre genere) { Title = title; Length = lenght; Genere = genere; }
private void MusicGenreControl1_GenreChanged(MusicGenre genre) { chosenGenreTextBox.Text = genre.ToString(); }
public ActionResult Add(ClubBindingViewModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var user = this.users.GetAll() .Where(u => u.UserName == this.User.Identity.Name) .FirstOrDefault(); Image image = null; if (model.ProfilePic != null) { using (var memory = new MemoryStream()) { model.ProfilePic.InputStream.CopyTo(memory); var contentAsArray = memory.GetBuffer(); image = new Image { Content = contentAsArray }; } } this.images.Add(image); var genreInModel = this.genres.GetAll() .Where(g => g.Genre == model.Genre) .FirstOrDefault(); if (genreInModel == null) { genreInModel = new MusicGenre() { Genre = model.Genre }; this.genres.Add(genreInModel); } var clubToAdd = new Club() { Moderator = user, Name = model.Name, Adress = model.Adress, Phone = model.Phone, SiteUrl = model.SiteUrl, FacebookUrl = model.FacebookUrl, TwitterUrl = model.TwitterUrl, Email = model.Email, Capacity = model.Capacity, MusicGenre = genreInModel, ProfilePic = image }; this.clubs.Add(clubToAdd); this.TempData["Notification"] = "Club created successfully!"; return(this.RedirectToAction("Index", "Home")); // change later to browse action }