public IActionResult AddAd(NewAdVm model)
 {
     if (ModelState.IsValid)
     {
         _adService.AddAd(model);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Beispiel #2
0
        public async Task <IActionResult> AddAd([FromBody] AdDTO ad)
        {
            try
            {
                var userId = User.Claims.Where(x => x.Type == "id").FirstOrDefault().Value;
                var result = await _adService.AddAd(userId, ad);

                if (!result.IsSuccess())
                {
                    return(result.ToErrorResponse());
                }
                return(Ok(result.Data));
            }
            catch (Exception)
            {
                return(BadRequest("Σφάλμα, Επικοινωνήστε με τον διαχειριστή"));
            }
        }