public async Task <IActionResult> AddAdvertisement([FromBody] Advertisement advertisement)
        {
            var _advertisement = await _advertisementRepository.AddAdvertisement(advertisement);

            if (_advertisement == null)
            {
                return(NotFound("Anúncio não encontrado"));
            }
            else
            {
                return(Ok(_advertisement));
            }
        }
 public ActionResult Create([Bind(Include = "Title,CategoryId,Contents")] Advertisement advertisement)
 {
     if (ModelState.IsValid)
     {
         advertisement.UserId  = User.Identity.GetUserId();
         advertisement.AddDate = DateTime.Now;
         try
         {
             _repository.AddAdvertisement(advertisement);
             _repository.SaveChanges();
             return(RedirectToAction("MyAdvertisements"));
         }
         catch (Exception e)
         {
             return(View(advertisement));
         }
     }
     ViewBag.CategoryId = _repository.GetCategoriesList(advertisement.CategoryId);
     return(View(advertisement));
 }