public static void Main()
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("http://localhost:7661/")
            };

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var album = new Album
            {
                Title = "Runaway",
                Year = 1986,
                Producer = "Bon Jovi"
            };

            HttpResponseMessage response = client.PostAsJsonAsync("api/albums", album).Result;
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine("{0} added!", album.GetType().Name);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
Example #2
1
        public Album AmazonAlbumLookup(string albumId)
        {
            Album album = new Album();

            var helper = new SignedRequestHelper(Options.MainSettings.AmazonSite);
            string requestString = helper.Sign(string.Format(itemLookup, albumId));
            string responseXml = Util.GetWebPage(requestString);
            if (responseXml == null)
                return album;

            XmlDocument xml = new XmlDocument();
            xml.LoadXml(responseXml);

            // Retrieve default Namespace of the document and add it to the NameSpacemanager
            string defaultNameSpace = xml.DocumentElement.GetNamespaceOfPrefix("");
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(xml.NameTable);
            nsMgr.AddNamespace("ns", defaultNameSpace);

            XmlNodeList nodes = xml.SelectNodes("/ns:ItemLookupResponse/ns:Items/ns:Item", nsMgr);
            if (nodes.Count > 0)
            {
                album = FillAlbum(nodes[0]);
            }
            return album;
        }
Example #3
0
 public PlayListElems(Artist aid, Album alid, TrackList trid)
 {
     ArtistName = (string)aid.ArtistName;
     AlbumName = (string)alid.AlbumName;
     TrackNum = (string)trid.TrackNum;
     TrackName = (string)trid.TrackName;
 }
Example #4
0
        public bool AddAlbum(Album album)
        {
            using (var connection = new SqlConnection(this.connectionString))
            {
                var storeProcedure = "Album_AddAlbum";

                var command = new SqlCommand(storeProcedure, connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                command.Parameters.AddWithValue("@name", album.Name);
                var dateParameter = new SqlParameter("@date", SqlDbType.DateTime);
                dateParameter.Value = album.Date;
                command.Parameters.Add(dateParameter);
                command.Parameters.AddWithValue("@userId", album.UserId);

                connection.Open();
                var reader = command.ExecuteReader();
                if (reader.Read())
                {
                    album.Id = (int)(decimal)reader["newId"];
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
Example #5
0
        public static Db.Album ToEntity(Album album)
        {
            if (album != null)
            {
                var media = new List<DataAccess.Database.Entities.Objects.Media>();
                if (album.Media != null)
                {
                    media = album.Media.Select(MediaMapper.ToEntity).ToList();
                }

                return new Db.Album
                {
                    AlbumId = album.AlbumId,
                    AlbumName = album.AlbumName,
                    Media = media,
                    UserId = album.User.Id,
                    IsUserDefault = album.IsUserDefault,
                    CreatedBy = album.CreatedBy,
                    CreatedDate = album.CreatedDate,
                    ModifiedBy = album.ModifiedBy,
                    ModifiedDate = album.ModifiedDate
                };
            }
            return null;
        }
        // PUT api/Albums/5
        public HttpResponseMessage PutAlbum(int id, Album album)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != album.AlbumId)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            db.Entry(album).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
        /// <summary>
        /// Adds a new album to the database.
        /// </summary>
        /// <param name="creatorName">The username(email) of the requesting user.</param>
        /// <returns>The id of the created album.</returns>
        public int Add(Album newAlbum, string creatorName)
        {
            if (creatorName == null)
            {
                throw new ArgumentNullException("Creator name must be specified.");
            }

            if (newAlbum == null)
            {
                throw new ArgumentNullException("Album cannot be null.");
            }

            var currentUser = this.data.Users
                .All()
                .FirstOrDefault(u => u.UserName == creatorName);

            if (currentUser == null)
            {
                throw new ArgumentException("No user with this username found.");
            }

            newAlbum.CreatedOn = DateTime.Now;
            newAlbum.Owner = currentUser;

            this.data.Albums.Add(newAlbum);
            this.data.SaveChanges();

            return newAlbum.Id;
        }
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            if (EmptyNullUndefined(txtAlbumName.Text) || ddlYearReleased.SelectedValue == "-1")
                return;

            var album = new Album
            {
                AlbumId = Guid.NewGuid(),
                AlbumName = txtAlbumName.Text,
                CreatedDate = DateTime.UtcNow,
                YearReleased = int.Parse(ddlYearReleased.SelectedValue)
            };

            var albumService = new AlbumService(Ioc.GetInstance<IAlbumRepository>());

            bool success;
            albumService.SaveCommit(album, out success);

            if (success)
            {
                var scriptHelper = new ScriptHelper("SuccessAlert", "alertDiv", "You have successfully created an album.");
                Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetSuccessScript());
            }
            else
            {
                var scriptHelper = new ScriptHelper("ErrorAlert", "alertDiv", "There was an error, try again later.");
                Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetFatalScript());
            }
        }
		public EntryRefWithCommonPropertiesContract(Album entry, ContentLanguagePreference languagePreference)
			: base(entry, languagePreference) {

			ArtistString = entry.ArtistString[languagePreference];
			EntryTypeName = DiscTypeNames.ResourceManager.GetString(entry.DiscType.ToString());

		}
Example #10
0
 public async Task<HttpResponseMessage> Put([FromUri] int albumId, Album album)
 {
     var updated = await albumRepository.Update(albumId, album);
     return updated ?
         Request.CreateResponse(HttpStatusCode.NoContent) :
         Request.CreateResponse(HttpStatusCode.InternalServerError);
 }
 public PodcastArticle()
     : base()
 {
     Album1 = new Album();
       Album2 = new Album();
       PodcastUrl = new DynamicUrl();
 }
Example #12
0
        public ActionResult Create(Album album)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // Save Album
                    storeDB.AddToAlbums(album);
                    storeDB.SaveChanges();

                    return Redirect("Index");
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(String.Empty, ex);
            }

            // Invalid - redisplay with errors

            var viewModel = new StoreManagerViewModel()
            {
                Album = album,
                Genres = new SelectList(storeDB.Genres.ToList(), "GenreId", "Name", album.GenreId),
                Artists = new SelectList(storeDB.Artists.ToList(), "ArtistId", "Name", album.ArtistId)
            };

            return View(viewModel);
        }
        protected override void ExecuteInsertMediaCommand(string[] commandWords)
        {
            switch (commandWords[2])
            {
                case "album":
                    var performer = this.performers.FirstOrDefault(p => p.Name == commandWords[5]);
                    if (performer == null)
                    {
                        this.Printer.PrintLine("The performer does not exist in the database.");
                        return;
                    }

                    var album = new Album(
                        commandWords[3],
                        decimal.Parse(commandWords[4]),
                        performer, commandWords[6],
                        int.Parse(commandWords[7]));

                    this.InsertAlbum(album, performer);
                    break;
                default:
                    base.ExecuteInsertMediaCommand(commandWords);
                    break;
            }
        }
    private static void AddAlbum(string title, int? year, string producer, string artistName)
    {
        // Create a new album
        var newAlbum = new Album
        {
            AlbumTitle = title,
            AlbumYear = year,
            Producer = producer
        };

        Uri newAlbumUri = null;

        HttpResponseMessage response = Client.PostAsJsonAsync(
            string.Format("api/Albums?artistName={0}",
            artistName),
            newAlbum).Result;

        if (response.IsSuccessStatusCode)
        {
            newAlbumUri = response.Headers.Location;
            Console.WriteLine("AlbumId: " + newAlbumUri.Segments[3]);
        }
        else
        {
            Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
        }
    }
        public AlbumWithArchivedVersionsContract(Album album, ContentLanguagePreference languagePreference)
            : base(album, languagePreference)
        {
            ParamIs.NotNull(() => album);

            ArchivedVersions = album.ArchivedVersionsManager.Versions.Select(a => new ArchivedAlbumVersionContract(a)).ToArray();
        }
Example #16
0
        public void Create(Album album)
        {
            if (album == null)
                throw new ArgumentNullException("album");

            _repository.Add(album);
        }
Example #17
0
 public PlayListElems(Artist aid, Album alid, TrackList trid)
 {
     artistName = (string)aid.artistName;
     albumName = (string)alid.albumName;
     trackNum = (string)trid.trackNum;
     trackName = (string)trid.trackName;
 }
Example #18
0
 public Album(Album a)
 {
     this.setid = a.setid;
       this.title = a.title;
       this.desc = a.desc;
       this.photoid = a.photoid;
 }
Example #19
0
        public void Modify(Album album)
        {
            if (album == null)
                throw new ArgumentNullException("album");

            _repository.Update(album);
        }
Example #20
0
        public CreateAlbumResponse CreateAlbum(CreateAlbumRequest request)
        {
            var response = new CreateAlbumResponse();

            var album = new Album
            {
                Genre = _genreRepository.FindBy(request.GenreId),
                Artist = _artistRepository.FindBy(request.ArtistId),
                Title = request.Title,
                Description = request.Description,
                Price = request.Price,
                AlbumArtUrl = request.AlbumArtUrl
            };

            ThrowExceptionIfAlbumIsInvalid(album);

            _albumRepository.Add(album);

            _uow.Commit();

            MvcSiteMapProvider.SiteMaps.ReleaseSiteMap();

            response.Album = album.ConvertToAlbumView();

            return response;
        }
Example #21
0
        public async void ReadMyXML(string year, string month)
        {
            Albums = new Albums();

            Progress<int> progress = new Progress<int>((p) => { ProgressPercent = p; });

            BasicFileDownloader bidl = new BasicFileDownloader(ToAbsoluteUri("xmlalbums.aspx?ay=" + year + "&am=" + month));
            IRandomAccessStream s = await bidl.DownloadAsync(progress);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;
            settings.Async = true;
            XmlReader reader = XmlReader.Create(s.AsStream(), settings);
            reader.ReadStartElement("Model");
            reader.ReadStartElement("Albums");
            Count = 0;
            while (reader.IsStartElement())
            {
                string albumid = reader[0];
                string album = reader[2];
                string str = reader[1];
                str = str.Replace("_s.jpg", "");
                uint count = 0;
                if (uint.TryParse(reader[3], out count))
                {
                    Album m = new Album(albumid, album, str, count);
                    Albums.Add(m);
                    Count += m.Count;
                }
                await reader.ReadAsync();
            }
        }
		public EntryForApiContract(Album album, ContentLanguagePreference languagePreference, IEntryThumbPersister thumbPersister, bool ssl, 
			EntryOptionalFields includedFields)
			: this(album, languagePreference) {

			ArtistString = album.ArtistString[languagePreference];
			CreateDate = album.CreateDate;
			DiscType = album.DiscType;
			Status = album.Status;

			if (includedFields.HasFlag(EntryOptionalFields.MainPicture) && album.CoverPictureData != null) {
				MainPicture = new EntryThumbForApiContract(new EntryThumb(album, album.CoverPictureMime), thumbPersister, ssl);					
			}

			if (includedFields.HasFlag(EntryOptionalFields.Names)) {
				Names = album.Names.Select(n => new LocalizedStringContract(n)).ToArray();				
			}

			if (includedFields.HasFlag(EntryOptionalFields.Tags)) {
				Tags = album.Tags.Usages.Select(u => new TagUsageForApiContract(u)).ToArray();				
			}

			if (includedFields.HasFlag(EntryOptionalFields.WebLinks)) {
				WebLinks = album.WebLinks.Select(w => new ArchivedWebLinkContract(w)).ToArray();				
			}

		}
Example #23
0
        public static ValidationResult Validate(Album album)
        {
            ParamIs.NotNull(() => album);

            var errors = new List<string>();

            if (album.CoverPictureData == null)
                errors.Add(AlbumValidationErrors.NeedCover);

            if (album.DiscType == DiscType.Unknown)
                errors.Add(AlbumValidationErrors.NeedType);

            if (album.Artists.All(a => a.Artist == null))
                errors.Add(AlbumValidationErrors.NeedArtist);

            if (album.Names.Names.All(n => n.Language == ContentLanguageSelection.Unspecified))
                errors.Add(AlbumValidationErrors.UnspecifiedNames);

            if (album.OriginalReleaseDate.IsEmpty)
                errors.Add(AlbumValidationErrors.NeedReleaseYear);

            if (!album.Songs.Any())
                errors.Add(AlbumValidationErrors.NeedTracks);

            return new ValidationResult(errors);
        }
        public ActionResult Edit(int id = 0)
        {
//            Album album = db.Albums.Find(id);
            var album = new Album {Title = "AlbumTitle"};

//            if (album == null) return HttpNotFound();
            if (id == 0) return HttpNotFound();

//            ViewBag.GenreId = new SelectList(
//                db.Genres, "GenreId", "Name", album.GenreId);
            ViewBag.GenreId = new Dictionary<int, string>
            {
                {1, "Genre Name 1"},
                {2, "Genre Name 2"}
            };
//
//            ViewBag.ArtistId = new SelectList(
//                db.Artists, "ArtistId", "Name", album.ArtistId);
            ViewBag.ArtistId = new Dictionary<int, string>
            {
                {1, "Artist Name 1"},
                {2, "Artist Name 2"}
            };

            return View(album);
        }
Example #25
0
    private AlbumEditorUI(Album album, bool isnew)
    {
        Glade.XML gxml = new Glade.XML (null, "organizer.glade", "window3", null);
          gxml.Autoconnect (this);

          this._isnew = isnew;
          this._album = album;
          window3.Title = String.Format("Editing information for {0}", album.Title);
          window3.SetIconFromFile(DeskFlickrUI.ICON_PATH);

          label8.Text = "Edit";
          label9.Text = "Title: ";
          label10.Text = "Description: ";

          entry3.Text = album.Title;
          textview6.Buffer.Text = album.Desc;

          entry3.Changed += new EventHandler(OnTitleChanged);
          textview6.Buffer.Changed += new EventHandler(OnDescriptionChanged);

          button7.Clicked += new EventHandler(OnCancelButtonClicked);
          button8.Clicked += new EventHandler(OnSaveButtonClicked);

          image4.Pixbuf = PersistentInformation.GetInstance()
                            .GetSmallImage(album.PrimaryPhotoid);
          window3.ShowAll();
    }
Example #26
0
        public void AddToCart(Album album)
        {
            // Get the matching cart and album instances
            var cartItem = storeDB.Carts.SingleOrDefault(c => c.CartId == ShoppingCartId && c.AlbumId == album.Id);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new Cart
                {
                    AlbumId = album.Id,
                    CartId = ShoppingCartId,
                    Count = 1,
                    DateCreated = DateTime.Now
                };

                storeDB.Carts.Add(cartItem);
            }
            else
            {
                // If the item does exist in the cart, then add one to the quantity
                cartItem.Count++;
            }

            // Save changes
            storeDB.SaveChanges();
        }
 public OtherArtistForAlbum(Album album, string name, bool isSupport, ArtistRoles roles)
 {
     Album = album;
     Name = name;
     IsSupport = isSupport;
     Roles = roles;
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        user = Membership.GetUser();
        if (user != null)
            userName = user.UserName;

        if (Request.Params.AllKeys.Contains<string>("id"))
        {

            photoId = int.Parse(Request.Params.Get("id"));
            try
            {
                photo = new Photo(photoId);
                album = photo.getAlbum();
                photoUrl = "Photos/" + photo.getId() + ".jpg";
                comments = photo.getComments();
            }
            catch (Exception ex)
            {
                Response.Redirect("Default.aspx");
            }

        }
        else
        {
            Response.Redirect("Default.aspx");
        }
    }
		public AlbumForApiContract(
			Album album, AlbumMergeRecord mergeRecord, 
			ContentLanguagePreference languagePreference, 
			IEntryThumbPersister thumbPersister,
			bool ssl,
			AlbumOptionalFields fields) : this(album, mergeRecord, languagePreference, 
				fields.HasFlag(AlbumOptionalFields.Artists), 
				fields.HasFlag(AlbumOptionalFields.Names), 
				fields.HasFlag(AlbumOptionalFields.PVs), 
				fields.HasFlag(AlbumOptionalFields.Tags), 
				fields.HasFlag(AlbumOptionalFields.WebLinks)) {

			if (languagePreference != ContentLanguagePreference.Default || fields.HasFlag(AlbumOptionalFields.AdditionalNames)) {
				AdditionalNames = album.Names.GetAdditionalNamesStringForLanguage(languagePreference);
			}

			if (fields.HasFlag(AlbumOptionalFields.Identifiers)) {
				Identifiers = album.Identifiers.Select(i => new AlbumIdentifierContract(i)).ToArray();
			}

			if (thumbPersister != null && fields.HasFlag(AlbumOptionalFields.MainPicture) && !string.IsNullOrEmpty(album.CoverPictureMime)) {
				
				MainPicture = new EntryThumbForApiContract(new EntryThumb(album, album.CoverPictureMime), thumbPersister, ssl);

			}

		}
Example #30
0
 public SongInAlbum(Song song, Album album, int trackNumber, int discNumber)
 {
     Song = song;
     Album = album;
     TrackNumber = trackNumber;
     DiscNumber = discNumber;
 }
Example #31
0
        public Album EditAlbum(Album Album)
        {
            Console.WriteLine("Album Edited");

            return(Album);
        }
Example #32
0
		public Album ToPOCO()
		{
			Album album = new Album();
			if (name != null)
			{
				album.Name = name;
			}
			if (uri != null)
			{
				album.Uri = uri;
			}
			switch (album_type)
			{
			case "album":
				album.AlbumType = AlbumType.Album;
				break;
			case "compilation":
				album.AlbumType = AlbumType.Compilation;
				break;
			case "single":
				album.AlbumType = AlbumType.Single;
				break;
			}
			if (this.artists != null)
			{
				artist[] artists = this.artists;
				foreach (artist artist in artists)
				{
					album.Artists.Add(artist.ToPOCO());
				}
			}
			if (available_markets != null)
			{
				album.AvailableMarkets = available_markets.ToList();
			}
			if (external_ids != null)
			{
				album.ExternalId = external_ids.ToPOCO();
			}
			if (external_urls != null)
			{
				album.ExternalUrl = external_urls.ToPOCO();
			}
			if (genres != null)
			{
				album.Genres = genres.ToList();
			}
			if (href != null)
			{
				album.HREF = href;
			}
			if (id != null)
			{
				album.Id = id;
			}
			if (this.images != null)
			{
				image[] images = this.images;
				foreach (image image in images)
				{
					Image image2 = image.ToPOCO();
					if (image2 != null)
					{
						album.Images.Add(image2);
					}
				}
			}
			if (label != null)
			{
				album.Label = label;
			}
			album.Popularity = popularity;
			if (release_date != null && DateTime.TryParse(release_date, out DateTime result))
			{
				album.ReleaseDate = result;
			}
			if (release_date_precision != null)
			{
				album.ReleaseDatePrecision = release_date_precision;
			}
			if (tracks != null)
			{
				album.Tracks = tracks.ToPOCO<Track>();
			}
			if (type != null)
			{
				album.Type = type;
			}
			return album;
		}
Example #33
0
        protected override void Seed(MWContext context)
        {
            var img1 = new Image()
            {
                Name        = "First image",
                Position    = 1,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342555439430128.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342555439430128.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342555439430128.jpg",
                Visible     = true
            };
            var img2 = new Image()
            {
                Name        = "Second image",
                Position    = 2,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342555445974574.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342555445974574.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342555445974574.jpg",
                Visible     = true
            };
            var img3 = new Image()
            {
                Name        = "Trd image",
                Position    = 3,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342555455088788.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342555455088788.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342555455088788.jpg",
                Visible     = true
            };
            var img4 = new Image()
            {
                Name        = "Trd image",
                Position    = 4,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342555547920570.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342555547920570.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342555547920570.jpg",
                Visible     = true
            };
            var img5 = new Image()
            {
                Name        = "Trd image",
                Position    = 5,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342555555645712.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342555555645712.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342555555645712.jpg",
                Visible     = true
            };
            var img6 = new Image()
            {
                Name        = "Trd image",
                Position    = 6,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342555725336549.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342555725336549.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342555725336549.jpg",
                Visible     = true
            };
            var img7 = new Image()
            {
                Name        = "Trd image",
                Position    = 7,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342555759671530.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342555759671530.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342555759671530.jpg",
                Visible     = true
            };
            var img8 = new Image()
            {
                Name        = "Trd image",
                Position    = 8,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342555905681855.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342555905681855.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342555905681855.jpg",
                Visible     = true
            };
            var img9 = new Image()
            {
                Name        = "Trd image",
                Position    = 9,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342555940180068.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342555940180068.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342555940180068.jpg",
                Visible     = true
            };
            var img10 = new Image()
            {
                Name        = "Trd image",
                Position    = 10,
                AddedOn     = DateTime.Now,
                ImagePath   = "2017/04/1-first-album/Original/636342556071457397.jpg",
                ThumbPath   = "2017/04/1-first-album/Thumbs/636342556071457397.jpg",
                ResizedPath = "2017/04/1-first-album/Resized/636342556071457397.jpg",
                Visible     = true
            };


            var album = new Album()
            {
                Title            = "Album name sample",
                CreatedOn        = DateTime.Parse("01/04/2017"),
                Description      = "This is some basic description",
                Published        = true,
                ModifiedOn       = DateTime.Now,
                Occasion         = "Test",
                PreviewImagePath = "2017/04/1-first-album/Original/636342555455088788.jpg",
                Slug             = "1-first-album",
            };

            album.Images.Add(img1);
            album.Images.Add(img2);
            album.Images.Add(img3);
            album.Images.Add(img4);
            album.Images.Add(img5);
            album.Images.Add(img6);
            album.Images.Add(img7);
            album.Images.Add(img8);
            album.Images.Add(img9);
            album.Images.Add(img10);

            context.Albums.Add(album);
            context.SaveChanges();

            var post1 = new Post()
            {
                Title       = "Title of 1",
                UrlSlug     = "1_title_of_1",
                Description = "<p>Lorem Ipsum - это текст-'рыба', часто используемый в печати и вэб-дизайне.</p><p>Lorem Ipsum является стандартной 'рыбой' для текстов на латинице с начала XVI века. В то время некий безымянный печатник создал большую коллекцию размеров и форм шрифтов, используя Lorem Ipsum для распечатки образцов. Lorem Ipsum не только успешно пережил без заметных изменений пять веков, но и перешагнул в электронный дизайн. Его популяризации в новое время послужили публикация листов Letraset с образцами Lorem Ipsum в 60-х годах и, в более недавнее время, программы электронной вёрстки типа Aldus PageMaker, в шаблонах которых используется Lorem Ipsum.</p>",
                Tags        = new List <Tag>(),
                PostedOn    = DateTime.Now,
                Published   = true,
                ImagePath   = "8.jpg"
            };
            var post2 = new Post()
            {
                Title = "Title of 2", ImagePath = "8.jpg", UrlSlug = "2_slug2", Description = "<p>Lorem Ipsum - это текст-'рыба', часто используемый в печати и вэб-дизайне.</p><p>Lorem Ipsum является стандартной 'рыбой' для текстов на латинице с начала XVI века. В то время некий безымянный печатник создал большую коллекцию размеров и форм шрифтов, используя Lorem Ipsum для распечатки образцов. Lorem Ipsum не только успешно пережил без заметных изменений пять веков, но и перешагнул в электронный дизайн. Его популяризации в новое время послужили публикация листов Letraset с образцами Lorem Ipsum в 60-х годах и, в более недавнее время, программы электронной вёрстки типа Aldus PageMaker, в шаблонах которых используется Lorem Ipsum.</p>", Tags = new List <Tag>(), PostedOn = DateTime.Now, Published = true
            };
            var post3 = new Post()
            {
                Title = "Title of 3", ImagePath = "8.jpg", UrlSlug = "3_slug3", Description = "3Some long text3", Tags = new List <Tag>(), PostedOn = DateTime.Now, Published = true
            };
            var post4 = new Post()
            {
                Title = "Title of 4", ImagePath = "8.jpg", UrlSlug = "4_slug4", Description = "<p>Lorem Ipsum - это текст-'рыба', часто используемый в печати и вэб-дизайне.</p><p>Lorem Ipsum является стандартной 'рыбой' для текстов на латинице с начала XVI века. В то время некий безымянный печатник создал большую коллекцию размеров и форм шрифтов, используя Lorem Ipsum для распечатки образцов. Lorem Ipsum не только успешно пережил без заметных изменений пять веков, но и перешагнул в электронный дизайн. Его популяризации в новое время послужили публикация листов Letraset с образцами Lorem Ipsum в 60-х годах и, в более недавнее время, программы электронной вёрстки типа Aldus PageMaker, в шаблонах которых используется Lorem Ipsum.</p>", Tags = new List <Tag>(), PostedOn = DateTime.Now, Published = true
            };
            var post5 = new Post()
            {
                Title       = "Title of 5",
                UrlSlug     = "5_title_of_5",
                Description = "<p>Lorem Ipsum - это текст-'рыба', часто используемый в печати и вэб-дизайне. Lorem Ipsum является стандартной 'рыбой' для текстов на латинице с начала XVI века.</p><p>В то время некий безымянный печатник создал большую коллекцию размеров и форм шрифтов, используя Lorem Ipsum для распечатки образцов. Lorem Ipsum не только успешно пережил без заметных изменений пять веков, но и перешагнул в электронный дизайн. Его популяризации в новое время послужили публикация листов Letraset с образцами Lorem Ipsum в 60-х годах и, в более недавнее время, программы электронной вёрстки типа Aldus PageMaker, в шаблонах которых используется Lorem Ipsum.</p>",
                Tags        = new List <Tag>(),
                PostedOn    = DateTime.Now,
                Published   = true,
                ImagePath   = "8.jpg"
            };
            var post6 = new Post()
            {
                Title       = "Title of 6",
                UrlSlug     = "6_title_of_6",
                Description = "<p>Lorem Ipsum - это текст-'рыба', часто используемый в печати и вэб-дизайне. Lorem Ipsum является стандартной 'рыбой' для текстов на латинице с начала XVI века. В то время некий безымянный печатник создал большую коллекцию размеров и форм шрифтов, используя Lorem Ipsum для распечатки образцов. Lorem Ipsum не только успешно пережил без заметных изменений пять веков, но и перешагнул в электронный дизайн. Его популяризации в новое время послужили публикация листов Letraset с образцами Lorem Ipsum в 60-х годах и, в более недавнее время, программы электронной вёрстки типа Aldus PageMaker, в шаблонах которых используется Lorem Ipsum.</p>",
                Tags        = new List <Tag>(),
                PostedOn    = DateTime.Now,
                Published   = false,
                ImagePath   = "8.jpg"
            };

            var tag1 = new Tag()
            {
                Name = "FIRST"
            };
            var tag2 = new Tag()
            {
                Name = "SECOND"
            };
            var tag3 = new Tag()
            {
                Name = "THIRD"
            };
            var tag4 = new Tag()
            {
                Name = "FOURTH"
            };

            post1.Tags.Add(tag1);

            post2.Tags.Add(tag1);
            post2.Tags.Add(tag2);

            post3.Tags.Add(tag1);
            post3.Tags.Add(tag2);
            post3.Tags.Add(tag3);

            post4.Tags.Add(tag1);
            post4.Tags.Add(tag2);
            post4.Tags.Add(tag3);
            post4.Tags.Add(tag4);

            post5.Tags.Add(tag2);

            post6.Tags.Add(tag4);

            context.Posts.Add(post1);
            context.Posts.Add(post2);
            context.Posts.Add(post3);
            context.Posts.Add(post4);
            context.Posts.Add(post5);
            context.Posts.Add(post6);

            context.SaveChanges();



            context.Books.Add(new Book()
            {
                Title = "Defender Of Rainbows", Author = "Jacqueline J. Sharp", Year = 2015, Cover = "Paperback"
            });
            context.Books.Add(new Book()
            {
                Title = "Descendants Without Glory", Author = "Sebastian Harrison", Year = 2012, Cover = "Hard"
            });
            context.Books.Add(new Book()
            {
                Title = "Hunted By My Family", Author = "Amy Patel", Year = 2014, Cover = "Hard"
            });
            context.Books.Add(new Book()
            {
                Title = "Limits Of Electricity", Author = "Ewan Lawson", Year = 2011, Cover = "Paperback"
            });
            context.Books.Add(new Book()
            {
                Title = "Maverik The Parrot", Author = "Logan Paul", Year = 2017, Cover = "Savage"
            });
            context.SaveChanges();
        }
 public void Create(Album newAlbum)
 {
     db.Albums.Add(newAlbum);
     db.SaveChanges();
 }
Example #35
0
        // GET: Store/Details/5
        public ActionResult Details(int?id = 1)
        {
            Album album = db.Albums.Find(id);

            return(View(album));
        }
Example #36
0
 public static string ToHtmlAll(this Album album)
 {
     return($"<h4><a href=\"/Albums/Details?id={album.Id}\">{WebUtility.UrlDecode(album.Name)}</a></h4>");
 }
Example #37
0
 public SixthHandler(Album Album) : base(Album)
 {
 }
Example #38
0
        public ActionResult Edit(QuoteViewModel quoteVM)
        {
            if (ModelState.IsValid)
            {
                Quote quote = db.Quotes.FirstOrDefault(q => q.Id == quoteVM.Id);
                quote.Text         = quoteVM.Text;
                quote.Explanation  = quoteVM.Explanation;
                quote.Explicit     = quoteVM.Explicit;
                quote.DateModified = DateTime.Now;

                if (quoteVM.ArtistId == -1)
                {
                    Artist artist = db.Artists.FirstOrDefault(a => a.Name == quoteVM.ArtistName);
                    if (artist == null)
                    {
                        db.Artists.Add(new Artist()
                        {
                            Name = quoteVM.ArtistName, DateModified = DateTime.Now
                        });
                        db.SaveChanges();
                    }
                }

                if (quoteVM.AlbumArtistId == -1)
                {
                    Artist artist = db.Artists.FirstOrDefault(a => a.Name == quoteVM.AlbumArtistName);
                    if (artist == null)
                    {
                        db.Artists.Add(new Artist()
                        {
                            Name = quoteVM.AlbumArtistName, DateModified = DateTime.Now
                        });
                        db.SaveChanges();
                    }
                }



                if (quoteVM.ArtistId != -1)
                {
                    quote.Artist = db.Artists.Find(quoteVM.ArtistId);
                }
                else
                {
                    quote.Artist = db.Artists.SingleOrDefault(a => a.Name == quoteVM.ArtistName);
                }

                if (quoteVM.TrackId != -1)
                {
                    quote.Track = db.Tracks.Find(quoteVM.TrackId);
                }
                else
                {
                    Track track = db.Tracks.FirstOrDefault(t => t.Title == quoteVM.TrackName);
                    if (track == null)
                    {
                        quote.Track = new Track()
                        {
                            Title = quoteVM.TrackName, DateModified = DateTime.Now, ReleaseDate = quoteVM.TrackReleaseDate
                        };
                    }
                    else
                    {
                        quote.Track = track;
                    }
                }

                if (quoteVM.AlbumId != -1)
                {
                    quote.Track.Album = db.Albums.Find(quoteVM.AlbumId);
                }
                else
                {
                    Album album = db.Albums.FirstOrDefault(a => a.Title == quoteVM.AlbumName);
                    if (album == null)
                    {
                        quote.Track.Album = new Album()
                        {
                            Title = quoteVM.AlbumName, DateModified = DateTime.Now, ReleaseDate = quoteVM.AlbumReleaseDate
                        };

                        if (quoteVM.AlbumArtistId > -1)
                        {
                            quote.Track.Album.Artist = db.Artists.Find(quoteVM.AlbumArtistId);
                        }
                        else
                        {
                            if (quoteVM.AlbumArtistId == -1)
                            {
                                quote.Track.Album.Artist = db.Artists.SingleOrDefault(a => a.Name == quoteVM.AlbumArtistName);
                            }
                            else
                            {
                                //get the value of the newly added artist
                                quote.Track.Album.Artist = db.Artists.SingleOrDefault(a => a.Name == quoteVM.ArtistName);
                            }
                        }
                    }
                    else
                    {
                        quote.Track.Album = album;
                    }
                }


                db.Entry(quote).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                var artists = db.Artists.ToList();
                artists.Add(new Artist()
                {
                    Name = "Add New Artist", Id = -1
                });
                quoteVM.Artists = new SelectList(artists, "Id", "Name", quoteVM.ArtistId);

                var tracks = db.Tracks.ToList();
                tracks.Add(new Track()
                {
                    Title = "Add New Song", Id = -1
                });
                quoteVM.Tracks = new SelectList(tracks, "Id", "Title", quoteVM.TrackId);

                var albums = db.Albums.ToList();
                albums.Add(new Album()
                {
                    Title = "Add New Album", Id = -1
                });
                quoteVM.Albums = new SelectList(albums, "Id", "Title", quoteVM.AlbumId);
            }
            return(View(quoteVM));
        }
 public void Update(Album Album)
 {
     _context.Albums.Update(Album);
 }
 public async Task AddAsync(Album Album)
 {
     await _context.Albums.AddAsync(Album);
 }
Example #41
0
 /// <summary>
 /// Constructs an AlbumFolderInfo.
 /// </summary>
 /// <param name="owner">The Album that owns this info.</param>
 /// <param name="path">The virtual path of the folder.</param>
 /// <param name="isParent">True if the folder decribes the parent of the current Album view.</param>
 public AlbumFolderInfo(Album owner, string path, bool isParent)
     : this(owner, path)
 {
     _isParent = isParent;
 }
        public void Album_Create()
        {
            ISixteenBarsDb  mockDb   = new MockSixteenBarsDb();
            AlbumController ctrl     = new AlbumController(mockDb);
            Album           newAlbum = new Album()
            {
                Id          = 5,
                Title       = "Doggystyle",
                ReleaseDate = new DateTime(1993, 11, 23),
                Artist      = new Artist()
                {
                    Id   = 11,
                    Name = "Snoop Doggy Dogg"
                }
            };

            ctrl.Create(newAlbum);
            Assert.AreEqual(newAlbum.Title, mockDb.Albums.Find(5).Title, "Doggystyle not added.");
            Assert.AreEqual(newAlbum.ReleaseDate, mockDb.Albums.Find(5).ReleaseDate, "Doggystyle release date not 11/23/93.");
            Assert.AreEqual(newAlbum.Artist.Name, mockDb.Albums.Find(5).Artist.Name, "Snoop Doggy Dogg not added as artist for Doggystyle.");

            newAlbum = new Album()
            {
                Id          = 6,
                Title       = ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./",
                ReleaseDate = new DateTime(1993, 11, 23),
                Artist      = new Artist()
                {
                    Id   = 12,
                    Name = ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./"
                }
            };
            ctrl.Create(newAlbum);
            Assert.AreEqual(newAlbum.Title, mockDb.Albums.Find(6).Title, ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./ not added.");
            Assert.AreEqual(newAlbum.ReleaseDate, mockDb.Albums.Find(6).ReleaseDate, ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./ release date not 11/23/93.");
            Assert.AreEqual(newAlbum.Artist.Name, mockDb.Albums.Find(6).Artist.Name, ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./ not added as artist for .~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./.");

            newAlbum = new Album()
            {
                Id          = 7,
                Title       = "The Blueprint",
                ReleaseDate = new DateTime(2001, 9, 11),
                Artist      = new Artist()
                {
                    Id = 1
                }
            };
            ctrl.Create(newAlbum);
            Assert.AreEqual(newAlbum.Title, mockDb.Albums.Find(7).Title, "The Blueprint not added.");
            Assert.AreEqual(newAlbum.ReleaseDate, mockDb.Albums.Find(7).ReleaseDate, "The Blueprint release date not 9/11/01.");
            Assert.AreEqual("Jay-Z", mockDb.Albums.Find(7).Artist.Name, "Jay-Z not added as artist for The Blueprint.");


            newAlbum = new Album()
            {
                Id          = 8,
                Title       = "Because the Internet",
                ReleaseDate = new DateTime(2013, 12, 3),
                Artist      = new Artist()
                {
                    Id = 3
                }
            };
            ctrl.Create(newAlbum);
            Assert.IsNull(mockDb.Albums.Find(8), "Because the Internet was created twice");

            newAlbum = new Album()
            {
                Id          = 9,
                Title       = "Because the Internet",
                ReleaseDate = new DateTime(2013, 12, 3),
                Artist      = new Artist()
                {
                    Id   = 12,
                    Name = "Childish Gambino"
                }
            };
            ctrl.Create(newAlbum);
            Assert.IsNull(mockDb.Albums.Find(9), "Because the Internet was created twice");
            Assert.IsNull(mockDb.Artists.Find(12), "Childish Gambino was created twice");

            newAlbum = new Album()
            {
                Id          = 9,
                Title       = "The Blueprint",
                ReleaseDate = new DateTime(2015, 5, 4),
                Artist      = new Artist()
                {
                    Id   = 12,
                    Name = "Jay-Z Imposter"
                }
            };
            ctrl.Create(newAlbum);
            Assert.AreEqual(newAlbum.Title, mockDb.Albums.Find(9).Title, "The Blueprint from different artist not added.");
            Assert.AreEqual(newAlbum.ReleaseDate, mockDb.Albums.Find(9).ReleaseDate, "The Blueprint from different artist release date not 5/4/15.");
            Assert.AreEqual("Jay-Z Imposter", mockDb.Albums.Find(9).Artist.Name, "The Jay-Z Imposter not added as artist for The other Blueprint album.");
        }
Example #43
0
        public ActionResult Create(QuoteViewModel quoteVM)
        {
            if (ModelState.IsValid)
            {
                if (quoteVM.ArtistId == -1)
                {
                    Artist artist = db.Artists.FirstOrDefault(a => a.Name == quoteVM.ArtistName);
                    if (artist == null)
                    {
                        db.Artists.Add(new Artist()
                        {
                            Name = quoteVM.ArtistName, DateModified = DateTime.Now
                        });
                        db.SaveChanges();
                    }
                }

                if (quoteVM.AlbumArtistId == -1)
                {
                    Artist artist = db.Artists.FirstOrDefault(a => a.Name == quoteVM.AlbumArtistName);
                    if (artist == null)
                    {
                        db.Artists.Add(new Artist()
                        {
                            Name = quoteVM.AlbumArtistName, DateModified = DateTime.Now
                        });
                        db.SaveChanges();
                    }
                }



                Quote quote = new Quote();
                quote.Text         = quoteVM.Text;
                quote.DateModified = DateTime.Now;
                quote.Explicit     = quoteVM.Explicit;
                quote.Explanation  = quoteVM.Explanation;

                if (quoteVM.ArtistId != -1)
                {
                    quote.Artist = db.Artists.Find(quoteVM.ArtistId);
                }
                else
                {
                    quote.Artist = db.Artists.SingleOrDefault(a => a.Name == quoteVM.ArtistName);
                }

                if (quoteVM.TrackId != -1)
                {
                    quote.Track = db.Tracks.Find(quoteVM.TrackId);
                }
                else
                {
                    Track track = db.Tracks.FirstOrDefault(t => t.Title == quoteVM.TrackName);
                    if (track == null)
                    {
                        quote.Track = new Track()
                        {
                            Title = quoteVM.TrackName, DateModified = DateTime.Now, ReleaseDate = quoteVM.TrackReleaseDate
                        };
                    }
                    else
                    {
                        quote.Track = track;
                    }
                }


                if (quoteVM.AlbumId != -1)
                {
                    quote.Track.Album = db.Albums.Find(quoteVM.AlbumId);
                }
                else
                {
                    Album album = db.Albums.FirstOrDefault(a => a.Title == quoteVM.AlbumName);
                    if (album == null)
                    {
                        quote.Track.Album = new Album()
                        {
                            Title = quoteVM.AlbumName, DateModified = DateTime.Now, ReleaseDate = quoteVM.AlbumReleaseDate
                        };

                        if (quoteVM.AlbumArtistId > -1)
                        {
                            quote.Track.Album.Artist = db.Artists.Find(quoteVM.AlbumArtistId);
                        }
                        else
                        {
                            if (quoteVM.AlbumArtistId == -1)
                            {
                                quote.Track.Album.Artist = db.Artists.SingleOrDefault(a => a.Name == quoteVM.AlbumArtistName);
                            }
                            else
                            {
                                //get the value of the newly added artist
                                quote.Track.Album.Artist = db.Artists.SingleOrDefault(a => a.Name == quoteVM.ArtistName);
                            }
                        }
                    }
                    else
                    {
                        quote.Track.Album = album;
                    }
                }

                db.Quotes.Add(quote);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(quoteVM));
        }
Example #44
0
        private void CreateName(Album album, string val, ContentLanguageSelection language)
        {
            var name = album.CreateName(val, language);

            querySource.Add(name);
        }
Example #45
0
 public void Remove(Album albumIn) =>
 _albums.DeleteOne(album => album.Id == albumIn.Id);
Example #46
0
 public String[] ToStringArray()
 {
     String[] d = new string[5];
     Array.Copy(Album.ToStringArray(), d, 5);
     return(d);
 }
Example #47
0
        private static void PersistenceChinookSelectorDemo()
        {
            Console.WriteLine("\nPersistence Chinook Selector Demo");

            var container = new UnityContainer();

            UnityHelper.RegisterMappings(container);

            IUnitOfWork unitOfWork = (IUnitOfWork)container.Resolve <IChinookUnitOfWork>();
            IGenericRepository <Album> repository = unitOfWork.GetRepository <Album>();

            Console.WriteLine("\n" + unitOfWork.GetType().FullName + " with " + unitOfWork.DBMS.ToString());

            IQueryable <Album>     query = unitOfWork.GetQuery <Album>();
            IEnumerable <Album>    enumerable;
            IEnumerable <AlbumDTO> enumerableDTO;

            {
                Console.WriteLine("\nQuery");
                enumerable = query
                             .Where(x => x.AlbumId <= 3)
                             .ToList <Album>();
                foreach (Album album in enumerable)
                {
                    Console.WriteLine("Album: {0} - {1} - {2}", album.AlbumId, album.Title, (album.Artist == null ? "?" : album.Artist.Name));
                }
            }

            {
                Console.WriteLine("\nQuery DTO");
                AlbumDTO dto = new AlbumDTO();
                enumerableDTO = query
                                .Where(x => x.AlbumId <= 3)
                                .Select(dto.GetDTOSelector());
                foreach (AlbumDTO album in enumerableDTO)
                {
                    Console.WriteLine("Album: {0} - {1} - {2}", album.AlbumId, album.Title, album.ArtistLookupText);
                }
            }

            {
                Console.WriteLine("\nData Model => DTO => View Model => DTO => Data Model");

                // Data Model
                Album data = repository.GetById(1);
                if (data != null)
                {
                    Console.WriteLine("Album Data Model: {0} - {1} - {2} - {3}", data.AlbumId, data.Title, data.ArtistId,
                                      (data.Artist == null ? "?" : data.Artist.Name));

                    // Data Model => DTO
                    AlbumDTO dto = new AlbumDTO(data);
                    Console.WriteLine("       Album DTO: {0} - {1} - {2} - {3}", dto.AlbumId, dto.Title, dto.ArtistId,
                                      dto.ArtistLookupText);

                    // DTO => View Model
                    AlbumViewModel view = new AlbumViewModel(dto);
                    Console.WriteLine("Album View Model: {0} - {1} - {2} - {3}", view.AlbumId, view.Title, view.ArtistId,
                                      view.ArtistLookupText);

                    // Data Model => DTO
                    dto = (AlbumDTO)view.ToDTO();
                    Console.WriteLine("       Album DTO: {0} - {1} - {2} - {3}", dto.AlbumId, dto.Title, dto.ArtistId,
                                      dto.ArtistLookupText);

                    // Data Model
                    data = (Album)dto.ToData();
                    Console.WriteLine("Album Data Model: {0} - {1} - {2} - {3}", data.AlbumId, data.Title, data.ArtistId,
                                      (data.Artist == null ? "?" : data.Artist.Name));
                }
            }
        }
Example #48
0
        //
        // GET: /StoreManager/RemoveAlbum/5
        public IActionResult RemoveAlbum(int id)
        {
            Album album = db.Albums.Where(a => a.AlbumId == id).FirstOrDefault();

            return(View(album));
        }
Example #49
0
 public virtual bool Contains(Album album)
 {
     return(Album == album);
 }
Example #50
0
        public IActionResult Create([FromBody] Album album)
        {
            AlbumRepository repo = new AlbumRepository(_configuration);

            return(Ok(repo.Create(album)));
        }
Example #51
0
 public CartItem(Cart cart, Album album, int qty)
 {
     _cart  = cart;
     _album = album;
     _qty   = qty;
 }
Example #52
0
 public HomeModule()
 {
     //Dev Routes
     Get["/tweet-timer"] = _ => {
         TwitBot.StartTimer();
         return(View["index.cshtml"]);
     };
     Get["/form"] = _ => {
         List <Album> allAlbums = Album.GetAll();
         return(View["form.cshtml", allAlbums]);
     };
     Post["/form/album"] = _ => {
         List <Album> allAlbums = Album.GetAll();
         Album        newAlbum  = new Album(Request.Form["album-title"], Request.Form["album-date"]);
         newAlbum.Save();
         return(View["form.cshtml", allAlbums]);
     };
     Post["/form/song"] = _ => {
         List <Album> allAlbums = Album.GetAll();
         Song         newSong   = new Song(Request.Form["song-title"], Request.Form["song-lyrics"], Request.Form["song-album"]);
         newSong.Save();
         return(View["form.cshtml", allAlbums]);
     };
     Get["/import/{artist}"] = parameters => {
         return(View["index.cshtml"]);
         // return Genius.GetRequest("http://www.google.com");
     };
     //User Routes
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/{page}"] = parameters => {
         return(View[parameters.page + ".cshtml"]);
     };
     Get["/api/lyric-pile"] = _ => {
         string allLyrics = "";
         foreach (Song song in Song.GetAll())
         {
             allLyrics += song.Lyrics + " ";
         }
         return(allLyrics);
     };
     Get["/api/songs/{title}"] = parameters => {
         string title        = parameters.title;
         Song   foundSong    = Song.Find(title);
         object songResponse = new { title  = foundSong.Title,
                                     lyrics = foundSong.Lyrics,
                                     album  = Album.Find(foundSong.AlbumId).Title };
         return(songResponse);
     };
     Get["/api/albums/{title}"] = parameters => {
         string        title       = parameters.title;
         Album         foundAlbum  = Album.Find(title);
         List <object> albumTracks = new List <object> {
         };
         foreach (Song song in foundAlbum.GetSongs())
         {
             object newSong = new { title = song.Title, lyrics = song.Lyrics };
             albumTracks.Add(newSong);
         }
         object albumResponse = new { title       = foundAlbum.Title,
                                      releaseDate = foundAlbum.ReleaseDate.ToString(),
                                      tracks      = albumTracks };
         return(albumResponse);
     };
     Get["/api/all/count"] = _ => {
         Dictionary <string, int> results = Count.All();
         return(results);
     };
     Get["/api/songs/count/{title}"] = parameters => {
         string title     = parameters.title;
         Song   foundSong = Song.Find(title);
         Dictionary <string, int> results = Count.Song(foundSong, null);
         return(results);
     };
     Get["/api/albums/count/{title}"] = parameters => {
         string title      = parameters.title;
         Album  foundAlbum = Album.Find(title);
         Dictionary <string, int> results = Count.Album(foundAlbum, null);
         return(results);
     };
     Get["/api/spit/verse"] = _ => {
         MarkoVerse ourVerse = new MarkoVerse();
         return(ourVerse.SpitVerse());
     };
     Get["/api/spit/country"] = _ => {
         MarkoVerse ourVerse = new MarkoVerse(true);
         return(ourVerse.SpitVerse());
     };
     Get["/api/spit/{bars}"] = parameters => {
         int        bars     = parameters.bars;
         MarkoVerse ourVerse = new MarkoVerse();
         return(ourVerse.Spit(bars));
     };
 }
Example #53
0
      public ActionResult Create()
      {
          Album g = new Album();

          return(this.View(g));
      }
Example #54
0
      public ActionResult Delete(int id)
      {
          Album c = this.depot.Albums.Find(id);

          return(this.View(c));
      }
 public void Remove(Album Album)
 {
     _context.Remove(Album);
 }
Example #56
0
        public IActionResult UpdateById(int id, [FromBody] Album album)
        {
            AlbumRepository repo = new AlbumRepository(_configuration);

            return(Ok(repo.Update(album, id)));
        }
Example #57
0
        public static void Main(string[] args)
        {
            while (true)
            {
                Console.Clear();
                Console.WriteLine("Mediathek...\n");
                Console.WriteLine("1. Alle Alben anzeigen ->" + "\t" + "5. Album löschen ->");
                Console.WriteLine("2. Album mit Songs anzeigen ->" + "\t" + "6. Alben nach Genre ->");
                Console.WriteLine("3. Neues Album hinzufügen ->" + "\t" + "7. Alben nach Datum ->");
                Console.WriteLine("4. Änderungen ->" + "\t\t" + "8. Song suchen ->");
                Console.WriteLine("9. Exit");


                string Eingabe = Console.ReadLine();
                if (Eingabe == "1")
                {
                    var          test1 = new AdoData();
                    List <Album> list  = test1.GetAllAlbum();

                    if (list != null)
                    {
                        foreach (Album album in list)
                        {
                            Console.WriteLine(album.interpret + "  " + album.title + "  " + album.genre + "  " + album.datum);
                        }
                    }
                }
                else if (Eingabe == "2")
                {
                    var          test2    = new AdoData();
                    List <Album> list     = test2.GetAllAlbum();
                    List <Song>  songlist = test2.GetSongsFromAlbum();

                    Console.WriteLine("Album mit Songs: ");
                    Console.Write("Interpret: ");
                    string interpret = Console.ReadLine();
                    Console.Write("Albumtitel: ");
                    string title = Console.ReadLine();

                    var t = list.Where(p => p.interpret == interpret && p.title == title);
                    foreach (Album album in t)
                    {
                        var test = from a in t
                                   join so in songlist on a.albumID equals so.albumID
                                   select new { Interpret = a.interpret, Album = a.title, Song = so.songtitle };

                        //foreach (var aso in test)
                        //{
                        //    Console.WriteLine(aso);
                        //}
                        foreach (var item in test)
                        {
                            Console.WriteLine("{0,-10} {1,-10} {2,-10}", item.Interpret, item.Album, item.Song);
                        }
                        Console.WriteLine("Songs in Album:  {0} ", test.Count());
                        Console.WriteLine(System.Environment.NewLine);
                    }
                }
                else if (Eingabe == "3")
                {
                    Console.Write("Geben Sie den Interpreten ein: ");
                    string interpret = Console.ReadLine();
                    Console.Write("Geben Sie den Albumtitel ein: ");
                    string title = Console.ReadLine();
                    Console.Write("Geben Sie die Genre ein: ");
                    string genre = Console.ReadLine();

                    Album neuAlbum = new Album(interpret, title, genre);

                    var test3 = new AdoData();
                    test3.InsertAlbum(neuAlbum);
                }
                else if (Eingabe == "4")
                {
                    var          test4 = new AdoData();
                    List <Album> list  = test4.GetAllAlbum();

                    if (list != null)
                    {
                        foreach (Album album in list)
                        {
                            Console.WriteLine(album.interpret + "  " + album.title + "  " + album.genre);
                        }
                    }
                    Console.Write("Änderungen Album: ");
                    Console.Write("\nInterpret: ");
                    string interpret = Console.ReadLine();
                    Console.Write("Album Titel: ");
                    string title = Console.ReadLine();
                    Console.Write("Genre: ");
                    string genre = Console.ReadLine();

                    var test = list.Where(p => p.interpret == interpret && p.title == title && p.genre == genre);
                    foreach (Album album in test)
                    {
                        Console.WriteLine("Was wollen Sie Ändern? ");
                        Console.Write(album.interpret + " : ");
                        album.interpret = Console.ReadLine();
                        Console.Write(album.title + " : ");
                        album.title = Console.ReadLine();
                        Console.Write(album.genre + " : ");
                        album.genre = Console.ReadLine();
                        //Console.Write(album.imagepath + " :");
                        //Console.ReadLine();
                        Console.Write(album.datum + " : ");
                        album.datum = Convert.ToInt32(Console.ReadLine());

                        test4.UpdateAlbum(album);
                    }
                }
                else if (Eingabe == "5")
                {
                    var          test5 = new AdoData();
                    List <Album> list  = test5.GetAllAlbum();
                    foreach (Album album in list)
                    {
                        Console.WriteLine(album.interpret + " " + album.title + "   " + album.genre);
                    }


                    Console.WriteLine("\nWelcher Album soll gelöscht werden:  ");
                    Console.Write("Geben Sie den Interpreten ein: ");
                    string interpret = Console.ReadLine();
                    Console.Write("Geben Sie den Albumtitel ein: ");
                    string title = Console.ReadLine();
                    Console.Write("Geben Sie die Genre ein: ");
                    string genre = Console.ReadLine();



                    var test = list.Where(p => p.interpret == interpret && p.title == title && p.genre == genre);
                    foreach (Album album in test)
                    {
                        //Console.WriteLine(album.interpret);
                        test5.DeleteAlbum(album);
                    }
                }
                else if (Eingabe == "6")
                {
                    var          test6 = new AdoData();
                    List <Album> list  = test6.GetAllAlbum();

                    Console.WriteLine("Geben Sie die Genre ein: ");
                    string genre = Console.ReadLine();

                    var test = list.Where(p => p.genre == genre);
                    foreach (Album album in test)
                    {
                        Console.WriteLine(album.title + "  " + album.interpret);
                    }
                }
                else if (Eingabe == "7")
                {
                    var          test7 = new AdoData();
                    List <Album> list  = test7.GetAllAlbum();

                    Console.WriteLine("Alben von alt nach neu:");

                    var test = from l in list
                               orderby l.datum ascending
                               select l;

                    foreach (var album in test)
                    {
                        Console.WriteLine(album.datum + "  " + album.interpret + "  " + album.title);
                    }
                }
                else if (Eingabe == "8")
                {
                    var          test8    = new AdoData();
                    List <Album> list     = test8.GetAllAlbum();
                    List <Song>  songlist = test8.GetSongsFromAlbum();

                    Console.WriteLine("Gesuchter Song: ");
                    string songtitle = Console.ReadLine();

                    var t = songlist.Where(p => p.songtitle == songtitle);
                    foreach (Song song in t)
                    {
                        var test = from so in t
                                   join a in list on so.albumID equals a.albumID
                                   select new { Interpret = a.interpret, Album = a.title, Song = so.songtitle };

                        //foreach (var aso in test)
                        //{
                        //    Console.WriteLine(aso);
                        //}
                        foreach (var item in test)
                        {
                            Console.WriteLine("Gefunden in: ");
                            Console.WriteLine("{0,-10} {1,-10} {2,-10}", item.Interpret, item.Album, item.Song);
                        }
                    }
                }
                else if (Eingabe == "9")
                {
                    System.Environment.Exit(0);
                }
                else
                {
                    Console.WriteLine("Fehler in der Eingabe...");
                }
                Console.ReadLine();
            }
        }
Example #58
0
 private static string GetTracks(Album album)
 {
     return(album.Tracks.Count == 0
                         ? "There are currently no tracks in this album."
                         : string.Join("", album.Tracks.Select((track, index) => track.ToHtmlAll(album.Id, index + 1))));
 }
Example #59
0
 /// <summary>
 /// Constructs an AlbumFolderInfo.
 /// </summary>
 /// <param name="owner">The Album that owns this info.</param>
 /// <param name="path">The virtual path of the folder.</param>
 public AlbumFolderInfo(Album owner, string path)
     : base(owner, path)
 {
 }
Example #60
0
        public static void Export(Album album)
        {
            // Експорт списка панелей в ексель.

            // Открываем приложение
            var excelApp = new Microsoft.Office.Interop.Excel.Application {
                DisplayAlerts = false
            };

            if (excelApp == null)
            {
                return;
            }

            // Открываем книгу
            Workbook workBook = excelApp.Workbooks.Add();

            // Содержание
            try
            {
                Worksheet sheetContent = workBook.ActiveSheet as Worksheet;
                sheetContent.Name = "Содержание";
                sheetContentAlbumFill(sheetContent, album);
            }
            catch { }

            // Секции
            if (album.Sections.Count > 0)
            {
                try
                {
                    Worksheet sheetSections = workBook.Sheets.Add();
                    sheetSections.Name = "Секции";
                    ExportToExcel.sheetSectionFill(sheetSections, album);
                }
                catch { }
            }

            // Плитка
            try
            {
                Worksheet sheetTiles = workBook.Sheets.Add();
                sheetTiles.Name = "Плитка";
                ExportToExcel.sheetTileFill(sheetTiles, album);
            }
            catch { }

            // Этажи
            try
            {
                Worksheet sheetFloors = workBook.Sheets.Add();
                sheetFloors.Name = "Этажи";
                ExportToExcel.sheetFloorFill(sheetFloors, album);
            }
            catch { }

            // Панели
            try
            {
                Worksheet sheetPanels = workBook.Sheets.Add();
                sheetPanels.Name = "Панели";
                ExportToExcel.sheetPanelFill(album, sheetPanels);
            }
            catch { }

            // Ошибки
            if (Inspector.HasErrors)
            {
                try
                {
                    Worksheet sheetError = workBook.Sheets.Add();
                    sheetError.Name = "Ошибки";
                    sheetErrorFill(sheetError, album);
                }
                catch { }
            }

            // Измененные марки покраски
            if (ChangeJob.ChangeJobService.ChangePanels.Count > 0)
            {
                try
                {
                    Worksheet sheetPanels = workBook.Sheets.Add();
                    sheetPanels.Name = "Изменение";
                    sheetChangesFill(sheetPanels, album);
                }
                catch { }
            }

            // Показать ексель.
            // Лучше сохранить файл и закрыть!!!???
            string excelFile = Path.Combine(album.AlbumDir, "АКР_" + Path.GetFileNameWithoutExtension(album.DwgFacade) + ".xlsx");

            excelApp.Visible = true;
            workBook.SaveAs(excelFile);
        }