public void SetupTest() { _controller = new API.Controllers.TourArtefactController(true); _tourController = new API.Controllers.TourController(true); _artefactController = new API.Controllers.ArtefactController(true); ArtefactDto artefact = CreateTestArtefact(); ArtefactSimpleDto artefactSimple = new ArtefactSimpleDto() { Id = artefact.Id }; }
// GET: ArtefactInfo/Create public async Task <ActionResult> Create(int?artefactId) { bool artefact_Selected = artefactId.HasValue; ViewBag.ArteFactSelected = artefact_Selected; var request = new HTTPrequest(); List <ArtefactSimpleDto> artefactsList = new List <ArtefactSimpleDto>(); ArtefactSimpleDto artefact = new ArtefactSimpleDto(); List <SelectListItem> artefactDropdown = new List <SelectListItem>(); // Checks if page was access from Index of all MediaFiles, or Direct from a particular artefact if (artefact_Selected == true) { artefact = await request.Get <ArtefactSimpleDto>("api/artefact/" + artefactId); if (artefact == null) { return(HttpNotFound()); } else { artefactDropdown.Add(new SelectListItem() { Text = artefact.Id + ": " + artefact.Name, Value = artefact.Id.ToString() }); ViewBag.ArtefactName = artefact.Name; ViewBag.ArtefactID = artefact.Id.ToString(); } } else { artefactsList = await request.Get <List <ArtefactSimpleDto> >("api/artefact?pageNumber=0&numPerPage=5-0&isDeleted=false"); if (artefactsList != null && artefactsList.Any()) { foreach (var artefacts in artefactsList) { artefactDropdown.Add(new SelectListItem() { Text = artefacts.Id + ": " + artefacts.Name, Value = artefacts.Id.ToString() }); } } } ViewBag.ArtefactList = artefactDropdown; return(View()); }
// GET: TourDtoes/Edit/5 public async Task <ActionResult> Edit(int?id) { bool tour_Selected = id.HasValue; ViewBag.TourSelected = tour_Selected; var request = new HTTPrequest(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TourArtefactDto tourArtefact = await request.Get <TourArtefactDto>("api/tourArtefact/" + id); if (tourArtefact == null) { return(HttpNotFound()); } //TOUR CATEGORY List <SelectListItem> tourDropdown = new List <SelectListItem>(); tourDropdown = await PopulateTourDropdown(tour_Selected, tourArtefact.Tour.Id); ViewBag.TourList = tourDropdown; //GET Artefact and Pass through ViewBag var requestArtefact = new HTTPrequest(); ArtefactSimpleDto artefact = await requestArtefact.Get <ArtefactSimpleDto>("api/artefact/" + tourArtefact.Artefact.Id); ViewBag.artefact = artefact; //ARTEFACT CATEGORY DROPDOWN List <SelectListItem> artefactDropdown = new List <SelectListItem>(); artefactDropdown = await PopulateArtefactDropdown(); ViewBag.ArtefactList = artefactDropdown; return(View(tourArtefact)); }
TourArtefactDto CreateTestTourArtefact() { TourSimpleDto newTour = new TourSimpleDto { Id = CreateTestTour().Id, Name = CreateTestTour().Name }; ArtefactSimpleDto newArtefact = new ArtefactSimpleDto { Id = CreateTestArtefact().Id, Name = CreateTestArtefact().Name }; TourArtefactDto tourArtefact = new TourArtefactDto() { Id = 1, Tour = newTour, Artefact = newArtefact, Order = 5 }; tourArtefact = _controller.Create(tourArtefact); return(tourArtefact); }
// GET: TourDtoes/Edit/5 public async Task <ActionResult> Edit(int?id) { var request = new HTTPrequest(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TourDto tour = await request.Get <TourDto>("api/tour/" + id); if (tour == null) { return(HttpNotFound()); } List <ArtefactSimpleDto> artefactsList = new List <ArtefactSimpleDto>(); ArtefactSimpleDto artefact = new ArtefactSimpleDto(); List <SelectListItem> artefactDropdown = new List <SelectListItem>(); artefactsList = await request.Get <List <ArtefactSimpleDto> >("api/artefact?pageNumber=0&numPerPage=5-0&isDeleted=false"); if (artefactsList != null && artefactsList.Any()) { foreach (var artefacts in artefactsList) { artefactDropdown.Add(new SelectListItem() { Text = artefacts.Id + ":" + artefacts.Name, Value = artefacts.Id.ToString() }); } } ViewBag.ArtefactList = artefactDropdown; return(View(tour)); }