public async Task <HttpResponseMessage> CreateTrack(int albumid, int artistId, string email, string token, string trackName, string fileType)
        {
            try
            {
                if (_security.Verify(token, email, artistId))
                {
                    var model = new CreateTrackModel
                    {
                        TrackName = trackName,
                        AlbumId   = albumid,
                        ArtistId  = artistId,
                        UserEmail = email,
                        FileType  = fileType
                    };
                    model.Track = await Request.Content.ReadAsByteArrayAsync();

                    var id = _artist.CreateSingleTrack(model);
                    return(Request.CreateResponse(HttpStatusCode.Created, id));
                }

                //_artist.CreateSingleTrack();
                return(Request.CreateResponse(HttpStatusCode.Forbidden));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, e));
            }
        }
Exemplo n.º 2
0
        public int CreateSingleTrack(CreateTrackModel model)
        {
            var id   = Repository.CreateTrack(model);
            var path = string.Format("{0}/{1}/{2}", model.ArtistId, model.AlbumId, id);

            //CreateTrackDirectory(model, id);

            audioFileManager.Create(path, model.Track, id, model.FileType);

            return(id);
        }
Exemplo n.º 3
0
        public int CreateTrack(CreateTrackModel model)
        {
            var      trackId = -1;
            DateTime relaseDate;

            if (model.ReleaseDate == null)
            {
                relaseDate = DateTime.Now;
            }
            else
            {
                relaseDate = (DateTime)model.ReleaseDate;
            }
            try
            {
                log.Info("method : CreateTrack | action : starting db connections");
                using (var context = new sparrow_dbEntities())
                {
                    var album = new SPRW_TRACK()
                    {
                        ARTIST_ID          = model.ArtistId,
                        ALBUM_ID           = model.AlbumId,
                        ACT_IND            = false,
                        IS_REJECTED        = false,
                        RELEASE_DATE       = relaseDate,
                        NAME               = model.TrackName,
                        DESCRP             = model.Description,
                        LAST_MAINT_TIME    = DateTime.Now,
                        LAST_MAINT_USER_ID = model.UserEmail
                    };

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

                    trackId = album.TRACK_ID;
                    var trackQueue = new SPRW_TRACK_QUEUE
                    {
                        TRACK_ID     = trackId,
                        DATE_QUEUED  = DateTime.Now,
                        IS_REVIEWING = false,
                        TRACK_PATH   = ""
                    };

                    context.SPRW_TRACK_QUEUE.Add(trackQueue);
                    context.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(trackId);
        }
Exemplo n.º 4
0
        private void CreateTrackDirectory(CreateTrackModel model, int trackId)
        {
            var albums   = String.Empty;
            var blobName = System.Configuration.ConfigurationManager.AppSettings["BlobMusicName"];

            if (model.AlbumId == null)
            {
                albums = "/0";
            }
            else
            {
                albums = "/" + model.AlbumId;
            }
            var dir = model.ArtistId + albums + "/" + trackId + "/";

            try
            {
                //File.BasicStorageBlockBlobOperationsAsync(model.Track, dir, trackId, ".mp3", blobName).Wait();
            }
            catch (Exception e)
            {
                throw e;
            }
        }