public VMHuesped(Huesped huesped) { this.huespedID = huesped.huespedID; this.nombre = huesped.nombre; this.apellidoM = huesped.apellidoM; this.apellidoP = huesped.apellidoP; this.telefono = huesped.telefono; }
//[ValidateAntiForgeryToken] public JsonResult Create(Huesped huesped) { String mensaje = String.Empty; try { if (ModelState.IsValid) { var nuevoHuesped = db.huesped.Add(huesped); db.SaveChanges(); mensaje = "Se han Guardado los datos satisfactoriamente"; } } catch (Exception exc) { mensaje = "Hubo un error en el servidor: " + exc.Message; } return Json(mensaje, JsonRequestBehavior.AllowGet); }
public JsonResult AjaxDelete(Huesped huesped) { String mensaje = String.Empty; try { db.Entry(huesped).State = EntityState.Deleted; int c = db.SaveChanges(); mensaje = "Se ha eliminado libro correctamente"; } catch (Exception exc) { mensaje = "Hubo un error en el servidor: " + exc.Message; } //return Json(new { mensaje = mensaje }, JsonRequestBehavior.AllowGet); return Json("Response from Delete", JsonRequestBehavior.AllowGet); }
public JsonResult AjaxEdit(Huesped huesped) { String mensaje = String.Empty; try { db.Entry(huesped).State = EntityState.Modified; int c = db.SaveChanges(); mensaje = "Se ha editado los datos del libro satisfactoriamente"; } catch (Exception exc) { mensaje = "Hubo un error en el servidor: " + exc.Message; } return Json(new { mensaje = mensaje }, JsonRequestBehavior.AllowGet); }