public ActionResult EditOrganization(OrgVM o) { ILocationRepo locorepo = LocationRepoFactory.Create(); IHeroRepo herorepo = HeroRepoFactory.Create(); IOrgRepo orgrepo = OrgRepoFactory.Create(); if (ModelState.IsValid) { o.OrganizationHeroes = new List <Hero>(); var orgToEdit = new Organization { OrganizationID = o.OrganizationID, OganizationAddress = o.OganizationAddress, OrganizationLocation = locorepo.GetLocationById(o.OrganizationLocation.LocationID), OrganizationName = o.OrganizationName, Phone = o.Phone, }; foreach (var HeroID in o.SelectedHeroesID) { orgToEdit.OrganizationHeroes.Add(herorepo.GetHereosByID(HeroID)); } orgrepo.EditOrg(orgToEdit); } return(RedirectToAction("OrganizationList")); }
public ActionResult EditLocation(int id) { ILocationRepo locorepo = LocationRepoFactory.Create(); var location = locorepo.GetLocationById(id); var model = new LocationVM { LocationID = location.LocationID, LocationName = location.LocationName, LocationAddress = location.LocationAddress, LocationDescription = location.LocationDescription, LatitudeCoordinate = location.LatitudeCoordinate, LongitudeCoordinate = location.LongitudeCoordinate, }; locorepo.EditLocation(location); return(View(model)); }
public ActionResult EditSighting(SightingVM s) { IHeroRepo herorepo = HeroRepoFactory.Create(); ISightingRepo repo = SightingRepoFactory.Create(); ILocationRepo locationrepo = LocationRepoFactory.Create(); if (ModelState.IsValid) { foreach (var hero in s.SightingHeroes) { s.SightingObject.SightingHeroes.Remove(hero); } foreach (var HeroID in s.SightingObject.SelectedHeroesID) { s.SightingObject.SightingHeroes.Add(herorepo.GetHereosByID(HeroID)); } s.SightingObject.SightingLocation = locationrepo.GetLocationById(s.SightingObject.SightingLocation.LocationID); Sighting sighting = new Sighting { Ispublished = true, SightingHeroes = s.SightingObject.SightingHeroes, SightingID = s.SightingObject.SightingID, SightingLocation = s.SightingObject.SightingLocation, SightingDescription = s.SightingObject.SightingDescription, Date = s.SightingObject.Date }; repo.EditSighting(sighting); } else { return(View(s)); } return(RedirectToAction("Index", "Home")); }
public ActionResult <Location> GetLocationById(int id) { var officeLocation = _repository.GetLocationById(id); return(Ok(officeLocation)); }
public Location GetLocationById(int id) { Location location = repo.GetLocationById(id); return(location); }
/// <summary> /// Returns location by id /// </summary> /// <param name="id"></param> /// <returns></returns> public Location GetLocationById(int id) { return(repo.GetLocationById(id)); }