public async Task <ActionResult <SponsorDTO> > AddSponsor(SponsorDTO sponsor) { try{ return(new OkObjectResult(await _sponsorService.AddSponsor(sponsor))); } catch (System.Exception ex) { throw ex; } }
public ActionResult Create(SponsorsViewModel model) { if (ModelState.IsValid) { Sponsors sponsor = new Sponsors(); sponsor.InjectFrom(model); var createNewSponsor = sponsorService.AddSponsor(sponsor); if (createNewSponsor == null) { ModelState.AddModelError("Name", "The Name must be unique!"); return(View(model)); } } return(RedirectToAction(nameof(Index))); }