public ActionResult Edit(int id, ArtworkForExposureModel eA) { try { List <ExpositionArtwork> eafc = new List <ExpositionArtwork>(); eafc = ServicExpositionArtwork.ExpositionArtworksByIdExposition(id); String[] Priorities = eA.Order.Split(','); for (int i = 0; i < Priorities.Length; i++) { ExpositionArtwork expA = new ExpositionArtwork(); expA.exposureId = id; expA.artworkId = Convert.ToInt32(Priorities[i]); expA.Priority = i + 1; ServicExpositionArtwork.Update(expA); ServicExpositionArtwork.Commit(); } return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Exposure/Details/5 public ActionResult Details(int id) { if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IEnumerable <artwork> ListArtworkById = serviceA.ArtworkByIdArtwork(id); List <ArtworkForExposureModel> ArtById = new List <ArtworkForExposureModel>(); ShowroomdbContext ctx = new ShowroomdbContext(); //user Artist = ServiceU.GetById(u.fk_artist.Value); //ExpositionArtwork ExpositionArtwork = ServicExpositionArtwork.GetOneExpoByIdExpo(id); //space space = ServiceS.GetById(ExpositionArtwork.fk_space); //exposure exposure = service.GetById(id); //int? FkOwner = space.fk_owner; //user Owner = ServiceU.GetById(FkOwner.Value); if (ListArtworkById == null) { return(HttpNotFound()); } foreach (var x in ListArtworkById) { ArtworkForExposureModel ar = new ArtworkForExposureModel(); user Artist = ServiceU.GetById((int)x.artist_id); ExpositionArtwork ExpositionArtwork = ServicExpositionArtwork.GetOneExpoByIdExpo(id); space space = ServiceS.GetById(ExpositionArtwork.fk_space); exposure exposure = service.GetById(id); int? FkOwner = space.owner_id; user Owner = ServiceU.GetById(FkOwner.Value); ar.id = x.id; ar.name = x.name; ar.photo = x.phot; ar.ArtistName = Artist.firstName + Artist.lastName; ar.StartDate = exposure.SDate.Value; ar.EndDate = exposure.EDate.Value; ar.SpaceName = space.name; ar.SpaceAddress = space.adress; ar.OwnerName = Owner.firstName + Owner.lastName; ar.Priority = ServicExpositionArtwork.GetByIdArtworkAndIdExposure(id, x.id); ArtById.Add(ar); } return(View(ArtById.OrderBy(a => a.Priority).ToList())); }