Exemplo n.º 1
0
        public ActionResult EditHero(HeroVM h)
        {
            IHeroRepo herorepo = HeroRepoFactory.Create();
            IOrgRepo  orgrepo  = OrgRepoFactory.Create();

            if (ModelState.IsValid)
            {
                h.Organizations = new List <Organization>();

                var hero = new Hero
                {
                    HeroID      = h.HeroID,
                    HeroName    = h.HeroName,
                    Description = h.Description,
                    Sightings   = h.Sightings,
                    Superpower  = h.Superpower,
                };
                foreach (var OrganizationID in h.SelectedOrganizationsID)
                {
                    hero.Organizations.Add(orgrepo.GetOrganizationById(OrganizationID));
                }
                herorepo.EditHero(hero);
            }
            return(RedirectToAction("HeroList"));
        }
Exemplo n.º 2
0
        public ActionResult EditOrganization(int id)
        {
            IOrgRepo orgrepo = OrgRepoFactory.Create();
            var      org     = orgrepo.GetOrganizationById(id);
            var      model   = new OrgVM
            {
                OrganizationID     = org.OrganizationID,
                OrganizationName   = org.OrganizationName,
                OganizationAddress = org.OganizationAddress,
                Phone = org.Phone,
                OrganizationLocation = org.OrganizationLocation,
            };

            foreach (var Hero in org.OrganizationHeroes)
            {
                model.SelectedHeroesID.Add(Hero.HeroID);
            }
            return(View(model));
        }