コード例 #1
0
        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));
            }
        }
コード例 #2
0
 public IActionResult Get(int id)
 {
     try
     {
         if (id < 1)
         {
             throw new IndexOutOfRangeException("ID must be greater than 0 (" + where + ") (GET)");
         }
         SM.MusicFormat mf = S.ServiceLocator.Instance.MusicFormatService.Get(id);
         return(ApiControllerHelper.SendOk(this, new ApiResult <SM.MusicFormat>(HttpStatusCode.OK, null, mf), true));
     }
     catch (Exception ex)
     {
         return(ApiControllerHelper.SendError(this, ex));
     }
 }
コード例 #3
0
 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));
     }
 }