Пример #1
0
        // 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)));
        }
Пример #3
0
 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));
     }
 }
Пример #4
0
        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));
            }
        }
Пример #5
0
        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)));
        }
Пример #6
0
        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));
            }
        }