public IActionResult Upd(int id, [FromBody] Shop_upd supd) { try { if (id < 1) { throw new IndexOutOfRangeException("ID must be greater than 0 (" + where + ") (UPD)"); } if (supd is null) { throw new ArgumentNullException("Shop Upd Object Empty (" + where + ") (UPD)"); } if (supd.Name.Length == 0) { throw new DataException("Shop Name can't be BLANK (" + where + ") (UPD)"); } //if (!ModelState.IsValid) throw new ValidationException("Model is not meeting requirement"); SM.Shop s = new SM.Shop(id, supd.Name, supd.Address1, supd.Address2, supd.ZIP, supd.City, supd.Country, supd.Phone, supd.Email, supd.WebSite, supd.LocalisationURL, supd.Closed); bool UpdOk = S.ServiceLocator.Instance.shopService.Upd(s); 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.Shop s = S.ServiceLocator.Instance.shopService.Get(id); return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Shop>(HttpStatusCode.OK, null, s), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public IActionResult Add([FromBody] Shop_upd sadd) { try { if (sadd is null) { throw new ArgumentNullException("Shop Add Object Empty (" + where + ") (ADD)"); } if (sadd.Name.Length == 0) { throw new DataException("Shop Name can't be BLANK (" + where + ") (ADD)"); } //if (!ModelState.IsValid) throw new ValidationException("Model is not meeting requirement"); SM.Shop s = new SM.Shop(0, sadd.Name, sadd.Address1, sadd.Address2, sadd.ZIP, sadd.City, sadd.Country, sadd.Phone, sadd.Email, sadd.WebSite, sadd.LocalisationURL, sadd.Closed); s = S.ServiceLocator.Instance.shopService.Add(s); return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Shop>(HttpStatusCode.OK, null, s), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }