public HttpResponseMessage Create(HttpRequestMessage request, NewViewModel newVM)
        {
            return(CreateHttpRespond(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                var news = new New();
                news.UpdateNew(newVM);
                news.CreatedDate = DateTime.Now;
                _newService.Add(news);
                _newService.Save();

                var responseData = Mapper.Map <New, NewViewModel>(news);
                response = request.CreateResponse(HttpStatusCode.Created, responseData);
                return response;
            }));
        }
Ejemplo n.º 2
0
 public ActionResult Post([FromBody] News news)
 {
     return(Ok(
                newService.Save(news)
                ));
 }