public async Task <ActionResult> Edit(ArtefactInfoDto artefactInfo, HttpPostedFileBase ArtefactInfoFile) { var request = new HTTPrequest(); ArtefactInfoDto artefactInfo_editted = await request.Get <ArtefactInfoDto>("api/artefactInfo/" + artefactInfo.Id.ToString()); // Checks Name is not Null or Empty if (artefactInfo.Artefact.Id.ToString() == null || string.IsNullOrEmpty(artefactInfo.Artefact.Id.ToString())) { ViewBag.ValidationName = "Artefact is required."; return(View(artefactInfo)); } if (ModelState.IsValid) { artefactInfo_editted.Artefact = artefactInfo.Artefact; artefactInfo_editted.Content = artefactInfo.Content; artefactInfo_editted.Description = artefactInfo.Description; artefactInfo_editted.ArtefactInfoType = artefactInfo.ArtefactInfoType; if (ArtefactInfoFile != null) { HttpPostedFileBase mediaFile = Request.Files["ArtefactInfoFile"]; artefactInfo_editted.File = new byte[mediaFile.ContentLength]; mediaFile.InputStream.Read(artefactInfo_editted.File, 0, mediaFile.ContentLength); string fileExtension = Path.GetExtension(mediaFile.FileName); artefactInfo_editted.FileExtension = fileExtension; } artefactInfo = await request.Put <ArtefactInfoDto>("api/artefactInfo", artefactInfo_editted); return(RedirectToAction("Index")); } return(View(artefactInfo)); }
public async Task <ActionResult> Edit(StoreItemDto storeItem, HttpPostedFileBase imageFile) { // Checks Name is not Null or Empty if (string.IsNullOrEmpty(storeItem.Name)) { ViewBag.ValidationName = "Name field is required."; return(View(storeItem)); } var request = new HTTPrequest(); StoreItemDto storeItem_editted = await request.Get <StoreItemDto>("api/storeItem/" + storeItem.Id); if (ModelState.IsValid) { storeItem_editted.Name = storeItem.Name; storeItem_editted.Description = storeItem.Description; storeItem_editted.ModifiedDate = storeItem.ModifiedDate; storeItem_editted.InStock = storeItem.InStock; storeItem_editted.Cost = storeItem.Cost; storeItem_editted.ModifiedDate = DateTime.Now; await request.Put <StoreItemDto>("api/storeItem", storeItem_editted); return(RedirectToAction("Index", new { recentAction = "Editted", recentName = storeItem.Name, recentId = storeItem.Id })); } return(View(storeItem)); }
public async Task <ActionResult> Edit(ArtefactCategoryDto category, HttpPostedFileBase imageFile) { var request = new HTTPrequest(); ArtefactCategoryDto category_editted = await request.Get <ArtefactCategoryDto>("api/artefactCatergory/" + category.Id); if (ModelState.IsValid) { category_editted.Name = category.Name; category_editted.Description = category.Description; category_editted.ModifiedDate = DateTime.Now; HttpPostedFileBase imgFile = Request.Files["ImageFile"]; if (imageFile != null) { category_editted.Image = new byte[imageFile.ContentLength]; imageFile.InputStream.Read(category_editted.Image, 0, imageFile.ContentLength); } else { category_editted.Image = category_editted.Image; } await request.Put <ArtefactCategoryDto>("api/artefactCatergory", category_editted); return(RedirectToAction("Index", new { recentAction = "Editted", recentName = category.Name, recentId = category.Id })); } return(View(category)); }
public async Task <ActionResult> Edit(ArtefactDto artefact, HttpPostedFileBase imageFile) { // Checks Name is not Null or Empty if (string.IsNullOrEmpty(artefact.Name)) { ViewBag.ValidationName = "Name field is required."; return(View(artefact)); } var request = new HTTPrequest(); ArtefactDto artefact_editted = await request.Get <ArtefactDto>("api/artefact/" + artefact.Id); if (ModelState.IsValid) { artefact_editted.Name = artefact.Name; artefact_editted.Description = artefact.Description; artefact_editted.Measurement_Length = artefact.Measurement_Length; artefact_editted.Measurement_Height = artefact.Measurement_Height; artefact_editted.Measurement_Width = artefact.Measurement_Width; artefact_editted.AdditionalComments = artefact.AdditionalComments; artefact_editted.ArtefactCategory = artefact.ArtefactCategory; artefact_editted.Zone = artefact.Zone; artefact_editted.ModifiedDate = DateTime.Now; artefact_editted.XBound = artefact.XBound; artefact_editted.YBound = artefact.YBound; // HttpPostedFileBase imgFile = Request.Files["ImageFile"]; if (imageFile != null) { artefact_editted.Image = new byte[imageFile.ContentLength]; imageFile.InputStream.Read(artefact_editted.Image, 0, imageFile.ContentLength); string fileExtension = Path.GetExtension(imageFile.FileName); artefact_editted.ImageFileType = fileExtension; } else { artefact_editted.Image = artefact_editted.Image; artefact_editted.ImageFileType = artefact_editted.ImageFileType; } //if (artefact.Image != null) { artefact_editted.Image = artefact.Image; } await request.Put <ArtefactDto>("api/artefact", artefact_editted); return(RedirectToAction("Index", new { recentAction = "Editted", recentName = artefact.Name, recentId = artefact.Id })); } return(View(artefact)); }
public async Task <ActionResult> DeleteConfirmed(int id) { try { var request = new HTTPrequest(); StoreItemImageDto storeItemImage = await request.Get <StoreItemImageDto>("api/storeItemImage/" + id); storeItemImage.IsDeleted = true; await request.Put <StoreItemImageDto>("api/storeItemImage", storeItemImage); await request.Delete("api/storeItemImage/" + id.ToString()); return(RedirectToAction("Index")); } catch (Exception) { throw; } }
public async Task <ActionResult> Edit(ZoneDto zone) { // Checks Name is not Null or Empty if (string.IsNullOrEmpty(zone.Name)) { ViewBag.ValidationName = "Name field is required."; return(View(zone)); } var request = new HTTPrequest(); if (ModelState.IsValid) { await request.Put <ArtefactCategoryDto>("api/zone", zone); return(RedirectToAction("Index", new { recentAction = "Editted", recentName = zone.Name, recentId = zone.Id })); } return(View(zone)); }
public async Task <ActionResult> DeleteConfirmed(int id) { try { var request = new HTTPrequest(); ArtefactInfoDto artefactInfo = await request.Get <ArtefactInfoDto>("api/artefactInfo/" + id); artefactInfo.IsDeleted = true; await request.Put <ArtefactInfoDto>("api/artefactInfo", artefactInfo); await request.Delete("api/artefactInfo/" + id.ToString()); return(RedirectToAction("Index")); } catch (Exception) { throw; } }
public async Task <ActionResult> Edit(ExhibitionDto exhibition, HttpPostedFileBase imageFile) { if (string.IsNullOrEmpty(exhibition.Name)) { ViewBag.ValidationName = "Name field is required."; return(View(exhibition)); } var request = new HTTPrequest(); ExhibitionDto exhibition_editted = await request.Get <ExhibitionDto>("api/exhibition/" + exhibition.Id); if (ModelState.IsValid) { exhibition_editted.Name = exhibition.Name; exhibition_editted.Description = exhibition.Description; exhibition_editted.Price_Adult = exhibition.Price_Adult; exhibition_editted.Price_Concession = exhibition.Price_Concession; exhibition_editted.Price_Child = exhibition.Price_Child; exhibition_editted.StartDate = exhibition.StartDate; exhibition_editted.FinishDate = exhibition.FinishDate; exhibition_editted.Organiser = exhibition.Organiser; exhibition_editted.ModifiedDate = DateTime.Now; // HttpPostedFileBase imgFile = Request.Files["ImageFile"]; if (imageFile != null) { exhibition_editted.Image = new byte[imageFile.ContentLength]; imageFile.InputStream.Read(exhibition_editted.Image, 0, imageFile.ContentLength); string fileExtension = Path.GetExtension(imageFile.FileName); //exhibition_editted.ImageFileType = fileExtension; } else { exhibition_editted.Image = exhibition_editted.Image; //exhibition_editted.ImageFileType = exhibition_editted.ImageFileType; } await request.Put <ExhibitionDto>("api/exhibition", exhibition_editted); return(RedirectToAction("Index", new { recentAction = "Editted", recentName = exhibition.Name, recentId = exhibition.Id })); } return(View(exhibition)); }
public async Task <ActionResult> Edit(TourDto tour, HttpPostedFileBase imageFile) { if (string.IsNullOrEmpty(tour.Name)) { ViewBag.ValidationName = "Name field is required."; return(View(tour)); } var request = new HTTPrequest(); TourDto tour_editted = await request.Get <TourDto>("api/tour/" + tour.Id); if (ModelState.IsValid) { tour_editted.Name = tour.Name; tour_editted.Description = tour.Description; tour_editted.AgeGroup = tour.AgeGroup; tour_editted.ModifiedDate = DateTime.Now; await request.Put <TourDto>("api/tour", tour_editted); return(RedirectToAction("Index", new { recentAction = "Editted", recentName = tour.Name, recentId = tour.Id })); } return(View(tour)); }
public async Task <ActionResult> DeleteConfirmed(int id) { var request = new HTTPrequest(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExhibitionDto exhibition = await request.Get <ExhibitionDto>("api/exhibition/" + id); if (exhibition == null) { return(HttpNotFound()); } exhibition.IsDeleted = true; var requestDelete = new HTTPrequest(); exhibition = await requestDelete.Put <ExhibitionDto>("api/exhibition", exhibition); await request.Delete("api/exhibition/" + id.ToString()); return(RedirectToAction("Index", new { recentAction = "Deleted", recentName = exhibition.Name, recentId = exhibition.Id })); }
public async Task <ActionResult> Edit(StoreItemImageDto storeItemImage, HttpPostedFileBase storeItemImageFile) { var request = new HTTPrequest(); StoreItemImageDto storeItemImage_editted = await request.Get <StoreItemImageDto>("api/storeItemImage/" + storeItemImage.Id.ToString()); if (ModelState.IsValid) { if (storeItemImageFile != null) { HttpPostedFileBase mediaFile = Request.Files["storeItemImageFile"]; storeItemImage_editted.Image = new byte[mediaFile.ContentLength]; mediaFile.InputStream.Read(storeItemImage_editted.Image, 0, mediaFile.ContentLength); string fileExtension = Path.GetExtension(mediaFile.FileName); storeItemImage_editted.FileType = fileExtension; } storeItemImage = await request.Put <StoreItemImageDto>("api/storeItemImage", storeItemImage_editted); return(RedirectToAction("Index")); } return(View(storeItemImage)); }
public async Task <ActionResult> Edit(TourArtefactDto tourArtefact, int?tourId) { // Checks Order is not Negative or Empty if (tourArtefact.Order < 0 || tourArtefact.Order == null) { ViewBag.OrderValidation = "Order must be a positive integer."; return(View(tourArtefact)); } var request = new HTTPrequest(); bool tour_Selected = tourId.HasValue; //TOUR CATEGORY List <SelectListItem> tourDropdown = new List <SelectListItem>(); if (tour_Selected) { tourDropdown = await PopulateTourDropdown(tour_Selected, tourId); } else { tourDropdown = await PopulateTourDropdown(tour_Selected, null); } ViewBag.TourList = tourDropdown; //ARTEFACT DROPDOWN List <SelectListItem> artefactDropdown = new List <SelectListItem>(); artefactDropdown = await PopulateArtefactDropdown(); ViewBag.ArtefactList = artefactDropdown; ViewBag.TourID = tourId.ToString(); var tourRequest = new HTTPrequest(); TourDto tourCheck = await tourRequest.Get <TourDto>("api/tour/" + tourArtefact.Tour.Id); TourArtefactDto newTourArtefact = await request.Get <TourArtefactDto>("api/tourArtefact/" + tourArtefact.Id.ToString()); TourSimpleDto tour = await tourRequest.Get <TourSimpleDto>("api/tour/" + tourArtefact.Tour.Id); TourArtefactDto tourArtefactCheck = await tourRequest.Get <TourArtefactDto>("api/tourArtefact/" + tourArtefact.Id); if (tourCheck.Artefacts.Any(m => m.Artefact.Id != tourArtefact.Artefact.Id && m.Order != tourArtefact.Order)) { ViewBag.IndexAvail = false; return(View(newTourArtefact)); } if (tourCheck.Artefacts.Any(m => m.Order == tourArtefact.Order)) { ViewBag.IndexAvail = false; return(View(newTourArtefact)); } if (tourArtefact.Order == tourArtefactCheck.Order) { ViewBag.IndexAvail = true; } if (ModelState.IsValid) { newTourArtefact.Id = tourArtefact.Id; newTourArtefact.Tour = tour; newTourArtefact.Order = tourArtefact.Order; newTourArtefact.Artefact = await tourRequest.Get <ArtefactSimpleDto>("api/artefact/" + tourArtefact.Artefact.Id); newTourArtefact.ModifiedDate = DateTime.Now; newTourArtefact = await request.Put <TourArtefactDto>("api/tourArtefact", newTourArtefact); return(RedirectToAction("Index", "ToursArtefacts", new { tId = tourArtefact.Tour.Id, recentAction = "Editted", recentNameT = newTourArtefact.Tour.Name, recentIdT = newTourArtefact.Tour.Id, recentNameA = newTourArtefact.Artefact.Name, recentIdA = newTourArtefact.Artefact.Id })); } return(View(newTourArtefact)); }