Example #1
0
 public IActionResult Post([FromBody] Publication publication)
 {
     if (ModelState.IsValid)
     {
         if (!PublicationDataBase.AddPublication(publication))
         {
             return(BadRequest());
         }
         return(Created(Url.Action("Post", publication.Id), publication));
     }
     return(BadRequest());
 }
Example #2
0
        public IActionResult Delete(int id)
        {
            var AuxPublication = PublicationDataBase.GetPublication(id);

            if (AuxPublication == null)
            {
                return(NotFound());
            }
            else if (!PublicationDataBase.DeletePublication(id))
            {
                return(BadRequest());
            }
            return(Ok());
        }
Example #3
0
 public ActionResult <IEnumerable <Publication> > Get(int id)
 {
     try
     {
         var ListPublication = PublicationDataBase.GetAreaPublications(id);
         if (ListPublication == null)
         {
             return(BadRequest());
         }
         return(Ok(ListPublication));
     }
     catch (InvalidOperationException)
     {
         return(NotFound());
     }
 }