public ActionResult Create([Bind(Include = "Id,CategoryId,DestinationPlaceId,Name,HotelName,Cost")] TourPackege tourPackege, HttpPostedFileBase ImageFile) { if (ImageFile == null) { ModelState.AddModelError("Image", "Please upload an image"); ViewBag.CategoryId = new SelectList(db.Categories.Where(c => c.MasterCategory.Id == 12), "Id", "Name", tourPackege.CategoryId); ViewBag.DestinationPlaceId = new SelectList(db.DestinationPlaces.Where(c => c.MasterCategory.Id == 12), "Id", "Name", tourPackege.DestinationPlaceId); return(View(tourPackege)); } bool IsValidFormat = common.ImageValidation(ImageFile); if (IsValidFormat == false) { ModelState.AddModelError("Image", "Only jpg, png, jpeg formates are allowed "); ViewBag.CategoryId = new SelectList(db.Categories.Where(c => c.MasterCategory.Id == 12), "Id", "Name", tourPackege.CategoryId); ViewBag.DestinationPlaceId = new SelectList(db.DestinationPlaces.Where(c => c.MasterCategory.Id == 12), "Id", "Name", tourPackege.DestinationPlaceId); return(View(tourPackege)); } byte[] convertedImage = common.ConvertImage(ImageFile); tourPackege.Image = convertedImage; if (ModelState.IsValid) { db.TourPackeges.Add(tourPackege); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories.Where(c => c.MasterCategory.Id == 12), "Id", "Name", tourPackege.CategoryId); ViewBag.DestinationPlaceId = new SelectList(db.DestinationPlaces.Where(c => c.MasterCategory.Id == 12), "Id", "Name", tourPackege.DestinationPlaceId); return(View(tourPackege)); }
// GET: TourPackeges/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TourPackege tourPackege = db.TourPackeges.Find(id); if (tourPackege == null) { return(HttpNotFound()); } return(View(tourPackege)); }
// GET: TourPackeges/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TourPackege tourPackege = db.TourPackeges.Find(id); if (tourPackege == null) { return(HttpNotFound()); } ViewBag.CategoryId = new SelectList(db.Categories.Where(c => c.MasterCategory.Id == 12), "Id", "Name", tourPackege.CategoryId); ViewBag.DestinationPlaceId = new SelectList(db.DestinationPlaces.Where(c => c.MasterCategory.Id == 12), "Id", "Name", tourPackege.DestinationPlaceId); return(View(tourPackege)); }
public PartialViewResult TourPackegesPartialDetail(int id) { TourPackege tourPackege = db.TourPackeges.Where(c => c.Id == id).FirstOrDefault(); return(PartialView("~/Views/Shared/TourPackeges/_PartialTourPackegeDetail.cshtml", tourPackege)); }