public ActionResult AddImage(HttpPostedFileBase file, AircraftImageViewModel viewModel) { if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["AircraftImages"]), fileName);//Path.Combine(Server.MapPath("~/Content/AircraftImages"), fileName); file.SaveAs(path); // create small, medium and large versions List <string> validationErrors = ImageHelper.CreateImageSet(path); if (validationErrors.Count > 0) { foreach (var error in validationErrors) { ModelState.AddModelError("", error); } return(View(ViewNames.AddAircraftImage, viewModel)); } AircraftImage image = new AircraftImage() { AircraftId = viewModel.AircraftId, Descritpion = viewModel.Description, Title = viewModel.Title, Type = viewModel.Type, FileName = fileName, FileName_Large = Path.GetFileNameWithoutExtension(fileName) + ".lrg" + Path.GetExtension(fileName), FileName_Medium = Path.GetFileNameWithoutExtension(fileName) + ".med" + Path.GetExtension(fileName), FileName_Small = Path.GetFileNameWithoutExtension(fileName) + ".small" + Path.GetExtension(fileName), }; _dataService.AddAircraftImage(image); } return(RedirectToAction("Edit", new { id = viewModel.AircraftId })); }
public ActionResult GetRates() { List <Aircraft> aircraft = _dataService.GetAllAirplanes(); List <AircraftListItemViewModel> vmList = new List <AircraftListItemViewModel>(); foreach (var ac in aircraft) { AircraftListItemViewModel vm = new AircraftListItemViewModel() { RegistrationNumber = ac.RegistrationNumber, HourlyRate = ac.HourlyRate.ToString(), Make = ac.Make, Model = ac.Model, CheckoutRequirements = ac.CheckoutRequirements }; if (ac.Images.Count > 0) { AircraftImage img = ac.Images.FirstOrDefault(im => im.Type == AircraftImageTypes.ExteriorMain.ToString()); if (img != null) { vm.ImageUrl = Url.Content(ConfigurationManager.AppSettings["AircraftImages"] + "/" + img.FileName_Small); } } vmList.Add(vm); } return(View(ViewNames.AircraftRates, vmList)); }
void ReleaseDesignerOutlets() { if (AircraftDetailsLabel != null) { AircraftDetailsLabel.Dispose(); AircraftDetailsLabel = null; } if (AircraftImage != null) { AircraftImage.Dispose(); AircraftImage = null; } if (AircraftNameLabel != null) { AircraftNameLabel.Dispose(); AircraftNameLabel = null; } if (NotesButton != null) { NotesButton.Dispose(); NotesButton = null; } if (NotesLabel != null) { NotesLabel.Dispose(); NotesLabel = null; } }
void ReleaseDesignerOutlets() { if (AdDescription != null) { AdDescription.Dispose(); AdDescription = null; } if (AircraftImage != null) { AircraftImage.Dispose(); AircraftImage = null; } if (AircraftNameLabel != null) { AircraftNameLabel.Dispose(); AircraftNameLabel = null; } if (BrokerNameLabel != null) { BrokerNameLabel.Dispose(); BrokerNameLabel = null; } if (ManufacturerLabel != null) { ManufacturerLabel.Dispose(); ManufacturerLabel = null; } if (PriceLabel != null) { PriceLabel.Dispose(); PriceLabel = null; } }
public void AddAircraftImage(AircraftImage image) { _repository.Add <AircraftImage>(image); _repository.UnitOfWork.SaveChanges(); }