コード例 #1
0
 public async Task <ActionResult <SponsorDTO> > AddSponsor(SponsorDTO sponsor)
 {
     try{
         return(new OkObjectResult(await _sponsorService.AddSponsor(sponsor)));
     }
     catch (System.Exception ex) {
         throw ex;
     }
 }
コード例 #2
0
        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)));
        }