public IHttpActionResult Add(ShareModel model) { try { return(Ok(shareService.Add(model))); } catch (Exception e) { throw new Exception(e.Message); } }
public Result Add(Shares mf) { var result = new Result(); try { ShareService SharesService = new ShareService(); SharesService.Add(mf); result.IsSuccess = true; } catch (Exception exception) { result.IsSuccess = false; result.ExceptionInfo = exception; } return(result); }
// POST: api/Share public HttpResponseMessage Post([FromBody] Share share) { var response = Request.CreateResponse <Share>(HttpStatusCode.Created, share); try { service.Add(share); } catch (Exception e) { response = Request.CreateResponse <Share>(HttpStatusCode.BadRequest, share); return(response); } string uri = Url.Link("DefaultApi", new { id = share.UserId }); response.Headers.Location = new Uri(uri); return(response); }
// POST api/<controller> public void Post([FromBody] ShareModel entity) { _service.Add(entity); }