Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Userid,FirstName,LastName,DisplayName,Gender,Age,Bio,UserAccountId")] UserProfile userProfile,
                                                 IFormFile FilePhoto)
        {
            if (FilePhoto != null)
            {
                string photoPath = _webroot.WebRootPath + "\\userPhotos\\";
                var    fileName  = Path.GetFileName(FilePhoto.FileName);

                using (var stream = System.IO.File.Create(photoPath + fileName))
                {
                    await FilePhoto.CopyToAsync(stream);

                    userProfile.PhotoPath = fileName;
                }
            }



            if (ModelState.IsValid)
            {
                _context.Add(userProfile);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Browse)));
            }
            return(View(userProfile));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("TrackId,Name,ArtistName,GenreName,AlbumName,ReleaseYear,Uploader,UploadDate,FileLocation")] SongInfo songInfo,
                                                 IFormFile FileMusic)
        {
            if (FileMusic.Length > 0)
            {
                string FileLocation = _webroot.WebRootPath + "\\uploads\\";
                var    fileName     = Path.GetFileName(FileMusic.FileName);

                using (var stream = System.IO.File.Create(FileLocation + fileName))
                {
                    await FileMusic.CopyToAsync(stream);

                    songInfo.FileLocation = fileName;
                }
            }

            if (ModelState.IsValid)
            {
                _context.Add(songInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(songInfo));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("PlaylistId,PlaylistCreator,PlaylistName")] UserPlaylist userPlaylist)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userPlaylist);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(userPlaylist));
        }