public IActionResult Upd(int id, [FromBody] MusicType mt) { try { if (id < 1) { throw new IndexOutOfRangeException("ID must be greater than 0 (" + where + ") (UPD)"); } if (mt is null) { throw new ArgumentNullException("Music Type Object Empty (" + where + ") (UPD)"); } if (mt.Name.Length == 0) { throw new DataException("Music Type NAme can't be BLANK (" + where + ") (UPD)"); } SM.MusicType mto = new SM.MusicType(id, mt.Name); bool UpdOk = S.ServiceLocator.Instance.MusicTypeService.Upd(mto); 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.MusicType mt = S.ServiceLocator.Instance.MusicTypeService.Get(id); return(ApiControllerHelper.SendOk(this, new ApiResult <SM.MusicType>(HttpStatusCode.OK, null, mt), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public IActionResult Add([FromBody] MusicType mt) { try { if (mt is null) { throw new ArgumentNullException("Music Type Object Empty (" + where + ") (ADD)"); } if (mt.Name.Length == 0) { throw new DataException("Music Type NAme can't be BLANK (" + where + ") (ADD)"); } SM.MusicType mto = new SM.MusicType(0, mt.Name); mto = S.ServiceLocator.Instance.MusicTypeService.Add(mto); return(ApiControllerHelper.SendOk(this, new ApiResult <SM.MusicType>(HttpStatusCode.OK, null, mto), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }