Exemplo n.º 1
0
 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);
        }
Exemplo n.º 3
0
        // 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);
        }
Exemplo n.º 4
0
 // POST api/<controller>
 public void Post([FromBody] ShareModel entity)
 {
     _service.Add(entity);
 }