public IActionResult Add([FromBody] MusicAPI mus) { try { if (mus is null) { throw new ArgumentNullException("Music Object Empty (" + where + ") (ADD)"); } if (mus.Band.Length == 0) { throw new DataException("Band Name can't be BLANK (" + where + ") (ADD)"); } if (mus.Title.Length == 0) { throw new DataException("Title can't be BLANK (" + where + ") (ADD)"); } SM.Music musa = new SM.Music(0 , mus.Band, mus.Title, mus.YEAR, mus.TRACKS, mus.NbCDs, mus.NbDvds, mus.NbLps, mus.MTypeId, mus.FormatId, mus.SerialNbr, mus.Ctry, "", "", mus.Price, mus.Curr, mus.ShopId, "", mus.Date, 1, mus.Signed, mus.SignedBy, mus.EAN, mus.EAN_EXT, mus.Comment1, mus.Comment2, mus.Onwed ); musa = S.ServiceLocator.Instance.MusicService.Add(musa); return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Music>(HttpStatusCode.OK, null, musa), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public IActionResult Upd(int id, [FromBody] MusicAPI mus) { try { if (mus is null) { throw new ArgumentNullException("Music Object Empty (" + where + ") (UPD)"); } SM.Music musa = new SM.Music(id , mus.Band, mus.Title, mus.YEAR, mus.TRACKS, mus.NbCDs, mus.NbDvds, mus.NbLps, mus.MTypeId, mus.FormatId, mus.SerialNbr, mus.Ctry, "", "", mus.Price, mus.Curr, mus.ShopId, "", mus.Date, 1, mus.Signed, mus.SignedBy, mus.EAN, mus.EAN_EXT, mus.Comment1, mus.Comment2, mus.Onwed); bool UpdOk = S.ServiceLocator.Instance.MusicService.Upd(musa); return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, UpdOk), HttpStatusCode.OK)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public IActionResult Get(int id) { try { if (id < 1) { throw new IndexOutOfRangeException("ID must be greater than 0 (" + where + ") (GET)"); } SM.Music mus = S.ServiceLocator.Instance.MusicService.Get(id); // OBJECT2 LIST SHOP // OBJECT3 LIST MUSIC FORMAT // ... // creare un object avec totues les auters object. return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Music>(HttpStatusCode.OK, null, mus), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }