// GET: Sponsors/Details/5 public ActionResult Details(int id) { Sponsors sponsors = sponsorsService.GetSponsorById(id); SponsorsViewModel model = new SponsorsViewModel(); sponsors.InjectFrom(sponsors); return(View(sponsors)); }
public ActionResult Edit(int id, SponsorsViewModel model) { Sponsors sponsor = new Sponsors(); sponsor.InjectFrom(model); var sponsorToUpdate = sponsorService.UpdateSponsor(sponsor); return(RedirectToAction(nameof(Index))); }
public ActionResult Edit(int id, SponsorsViewModel model) { if (ModelState.IsValid) { Sponsors sponsors = new Sponsors(); sponsors.InjectFrom(model); var sponsorToUpdate = sponsorsService.UpdateSponsor(sponsors); return(RedirectToAction(nameof(Index))); } else { return(View(model)); } }
public ActionResult Edit(int id, SponsorViewModel model) { if (ModelState.IsValid) { Sponsors sponsorsToCreate = new Sponsors(); sponsorsToCreate.InjectFrom(model); sponsor.Update(sponsorsToCreate); return(RedirectToAction(nameof(Index))); } else { return(View(model)); } }
public ActionResult Create(Sponsors model) { if (ModelState.IsValid) { Sponsors sponsors = new Sponsors(); sponsors.InjectFrom(model); var createNewSponsor = sponsorsService.AddSponsor(sponsors); if (createNewSponsor == null) { ModelState.AddModelError("Name", "Sponsors name must be unique!"); return(View(model)); } } return(RedirectToAction(nameof(Index))); }
public ActionResult Create(SponsorViewModel model) { if (ModelState.IsValid) { Sponsors sponsorToCreate = new Sponsors(); sponsorToCreate.InjectFrom(model); var sponsorToAdd = sponsor.Create(sponsorToCreate); if (sponsorToAdd == null) { ModelState.AddModelError("SponsorTypeId", "Sponsor Type Id must be unique"); return(View(model)); } return(RedirectToAction(nameof(Index))); } else { return(View(model)); } }