public ActionResult Create([Bind(Include = "eventDescription,eventCategory,eventStartDate,eventEndDate,eventStartTime,eventEndTime,registration,adultPrice,childPrice,eventID,image")] eventsTable eventsTable, HttpPostedFileBase file) { //string fileName = Path.GetFileNameWithoutExtension(eventsTable.imageFile.FileName); //string extension = Path.GetExtension(eventsTable.imageFile.FileName); //fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; //eventsTable.image = "~/Content/Images/" + fileName; //fileName = Path.Combine(Server.MapPath("~/Content/Images"), fileName); //eventsTable.imageFile.SaveAs(fileName); if (ModelState.IsValid) { string ImageName = System.IO.Path.GetFileName(file.FileName); string physicalPath = Server.MapPath("~/Content/Images/" + ImageName); // save image in folder file.SaveAs(physicalPath); //save new record in database eventsTable.image = ImageName; db.eventsTables.Add(eventsTable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventsTable)); }
public IHttpActionResult PuteventsTable(int id, eventsTable eventsTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eventsTable.eventID) { return(BadRequest()); } db.Entry(eventsTable).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!eventsTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { eventsTable eventsTable = db.eventsTables.Find(id); db.eventsTables.Remove(eventsTable); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "eventDescription,eventCategory,eventStartDate,eventEndDate,eventStartTime,eventEndTime,registration,adultPrice,childPrice,eventID,image")] eventsTable eventsTable) { if (ModelState.IsValid) { db.Entry(eventsTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventsTable)); }
public IHttpActionResult PosteventsTable(eventsTable eventsTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.eventsTables.Add(eventsTable); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = eventsTable.eventID }, eventsTable)); }
public IHttpActionResult GeteventsTable(int id) { eventsTable eventsTable = db.eventsTables.Find(id); if (eventsTable == null) { return(NotFound()); } return(Ok(eventsTable)); }
public IHttpActionResult DeleteeventsTable(int id) { eventsTable eventsTable = db.eventsTables.Find(id); if (eventsTable == null) { return(NotFound()); } db.eventsTables.Remove(eventsTable); db.SaveChanges(); return(Ok(eventsTable)); }
// GET: eventsTables/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } eventsTable eventsTable = db.eventsTables.Find(id); if (eventsTable == null) { return(HttpNotFound()); } return(View(eventsTable)); }
public ActionResult Edit([Bind(Include = "eventDescription,eventCategory,eventStartDate,eventEndDate,eventStartTime,eventEndTime,registration,adultPrice,childPrice,eventID,image")] eventsTable eventsTable, HttpPostedFileBase file) { if (ModelState.IsValid) { string ImageName = System.IO.Path.GetFileName(file.FileName); string physicalPath = Server.MapPath("~/Content/Images/" + ImageName); // save image in folder file.SaveAs(physicalPath); //save new record in database eventsTable.image = ImageName; db.Entry(eventsTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventsTable)); }