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())); }
public ActionResult Create(ExposureModel exM) { try { if (ModelState.IsValid) { #region Intialisation ShowroomdbContext ctx = new ShowroomdbContext(); exposure Expo = new exposure(); List <artwork> la = new List <artwork>(); List <ArtworkForExposureModel> ArtForExpo = new List <ArtworkForExposureModel>(); ExpositionArtwork ar = new ExpositionArtwork(); #endregion #region PopulateExposition Expo.id = exM.id; Expo.SDate = exM.startDate; Expo.EDate = exM.endDate; Expo.name = exM.name; Expo.Archiver = false; service.Add(Expo); service.Commit(); #endregion #region PopulateExposureArtworks var a = exM.Order; Debug.WriteLine(a); int IdEpo = (service.GetIdByName(Expo.name)); Debug.WriteLine(IdEpo); DateTime DatePriority = DateTime.Now; Debug.WriteLine(DatePriority); int FkSpace = 1; String[] Priorities = a.Split(','); for (int i = 0; i < Priorities.Length; i++) { Debug.WriteLine("idddddddddds" + Priorities[i]); Debug.WriteLine("priiiiiiot" + (i + 1)); } for (int i = 0; i < Priorities.Length; i++) { ExpositionArtwork EA = new ExpositionArtwork(); EA.exposureId = IdEpo; EA.DateExpoPriority = DatePriority; EA.fk_space = FkSpace; EA.artworkId = Convert.ToInt32(Priorities[i]); EA.Priority = i + 1; ServiceArt.Add(EA); ServiceArt.Commit(); } #endregion return(RedirectToAction("Index")); } return(View()); } catch { return(View()); } }