public async Task <ActionResult> Create([Bind(Include = "TourPackageID,TourPackageTitle,Highlights,InclusionExclusion,TourDestination,SpecialNotes,TourCostPrice,TourSalesPrice,TourDiscountPrice,TotalNights,HotelStar,HotelInUse,DayWiseItienary,TearmsAndConditions,Allotment,Adults,Childrens,CreatedOn,DepartingDate,ValidityDate,DayOne,DayTwo,DayThree,DayFour,DayFive,DaySix,DaySeven,DayEight,DayNine,DayTen")] TourPackage tourPackage) { if (ModelState.IsValid) { db.TourPackages.Add(tourPackage); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tourPackage)); }
public async Task <ActionResult> Create([Bind(Include = "TourPackageID,TourPackageTitle,Highlights,InclusionExclusion,TourDestination,SpecialNotes,TourCostPrice,TourSalesPrice,TourDiscountPrice,TotalNights,HotelStar,HotelInUse,DayWiseItienary,TearmsAndConditions,Allotment,Adults,Childrens,CreatedOn,DepartingDate,ValidityDate,DayOne,DayTwo,DayThree,DayFour,DayFive,DaySix,DaySeven,DayEight,DayNine,DayTen")] TourPackage tourPackage) { if (ModelState.IsValid) { List <FileDetail> fileDetails = new List <FileDetail>(); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); FileDetail fileDetail = new FileDetail() { FileName = fileName, Extension = Path.GetExtension(fileName), FileDetailsId = Guid.NewGuid() }; fileDetails.Add(fileDetail); var path = Path.Combine(Server.MapPath("~/Images/packageImg/"), fileDetail.FileDetailsId + fileDetail.Extension); file.SaveAs(path); } } //compound tourPackage.FileDetails = fileDetails; db.TourPackages.Add(tourPackage); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tourPackage)); }