internal static GM.MusicFormat ToGlobal(this MusicFormat mf)
 {
     return(new GM.MusicFormat()
     {
         Id = mf.Id, Name = mf.Name
     });
 }
Пример #2
0
        public void RequestFormat(ConsoleWriter consoleWriter = null)
        {
            var writer = consoleWriter != null ? consoleWriter : new ConsoleWriter(0);

            var formatOption = 0;

            writer.Write("- Formato: \n");
            writer.Write(text: "1. Mp3\n", indent: 1);
            writer.Write(text: "2. Mp4\n\n", indent: 1);
            writer.Write(text: "Escoge [1-2]: ", indent: 1);

            if (Int32.TryParse(ReadLine(), out formatOption))
            {
                switch (formatOption)
                {
                case 1:
                    Format = MusicFormat.Mp3;
                    break;

                case 2:
                    Format = MusicFormat.Mp4;
                    break;
                }
            }
        }
        public IActionResult Upd(int id, [FromBody] MusicFormat mf)
        {
            try
            {
                if (id < 1)
                {
                    throw new IndexOutOfRangeException("ID must be greater than 0 (" + where + ") (UPD)");
                }
                if (mf is null)
                {
                    throw new ArgumentNullException("Music Format Object Empty (" + where + ") (UPD)");
                }
                if (mf.Name.Length == 0)
                {
                    throw new DataException("Music Format NAme can't be BLANK (" + where + ") (UPD)");
                }

                SM.MusicFormat mfo   = new SM.MusicFormat(id, mf.Name);
                bool           UpdOk = S.ServiceLocator.Instance.MusicFormatService.Upd(mfo);
                return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, UpdOk), HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
Пример #4
0
        /// <summary>
        /// 返回某个音乐文件的格式
        /// </summary>
        /// <param name="mFileName">文件路径</param>
        /// <returns></returns>
        public MusicFormat GetMusicFormat(string mFileName)
        {
            MusicFormat mFormat = MusicFormat.Mp3;

            switch (mZPlay.GetFileFormat(mFileName))
            {
            case TStreamFormat.sfMp3:
                mFormat = MusicFormat.Mp3;
                break;

            case TStreamFormat.sfOgg:
                mFormat = MusicFormat.Ogg;
                break;

            case TStreamFormat.sfWav:
                mFormat = MusicFormat.Wav;
                break;

            case TStreamFormat.sfPCM:
                mFormat = MusicFormat.PCM;
                break;

            case TStreamFormat.sfFLAC:
                mFormat = MusicFormat.Flac;
                break;
            }
            return(mFormat);
        }
 public IActionResult Add([FromBody] MusicFormat mf)
 {
     try
     {
         if (mf is null)
         {
             throw new ArgumentNullException("Music Format Object Empty (" + where + ") (ADD)");
         }
         if (mf.Name.Length == 0)
         {
             throw new DataException("Music Format NAme can't be BLANK (" + where + ") (ADD)");
         }
         SM.MusicFormat mfo = new SM.MusicFormat(0, mf.Name);
         mfo = S.ServiceLocator.Instance.MusicFormatService.Add(mfo);
         return(ApiControllerHelper.SendOk(this, new ApiResult <SM.MusicFormat>(HttpStatusCode.OK, null, mfo), true));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }