public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } string callback = Request.Params["callback"]; if (string.IsNullOrEmpty(callback)) { callback = "AjaxOk"; } //var curso = new curso(); ViewBag.modo = "Edit"; ViewBag.Callback = callback; sede sede = db.sede.Find(id); if (sede == null) { return(HttpNotFound()); } return(View("Edit", sede)); }
public ActionResult DeleteConfirmed(int id) { try { sede sede = db.sede.Find(id); sede.borradoLogico = true; if (db.SaveChanges() > 0) { return(Json(new { ok = true })); } else { return(Json(new { error = true })); } } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; } ViewBag.ErrorMessage = string.Format(Strings.ErrorIntentarInsertarRegistro, e.Message.Replace(Strings.TheStatementHasBeenTerminated, "")); return(View()); } }
public async Task <IHttpActionResult> Getsede(int id) { sede sede = await db.sedes.FindAsync(id); if (sede == null) { return(NotFound()); } JObject _sede = JObject.FromObject(new { idComplejo = sede.idSEDE, nombre = sede.Nombre, direccion = new { ciudad = sede.ciudad, calle = sede.calle, avenida = sede.avenida, geo = new { lat = sede.lat, lng = sede.lng } }, email = sede.email }); return(Ok(_sede)); }
public ActionResult Create(sede sede) { try { if (ModelState.IsValid) { sede.borradoLogico = false; sede.sector = User.IsInRole("AdministradorEmpresas") == true ? (int)Sectores.Empresas : User.IsInRole("AdministradorGraduado") == true ? (int)Sectores.Graduados : (int)Sectores.Idiomas; db.sede.Add(sede); db.SaveChanges(); return(Json(new { ok = true })); //return RedirectToAction("Index"); } } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; } ViewBag.ErrorMessage = string.Format(Strings.ErrorIntentarInsertarRegistro, e.Message.Replace(Strings.TheStatementHasBeenTerminated, "")); } return(PartialView(sede)); }
public async Task <IHttpActionResult> Putsede(int id, sede sede) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sede.id) { return(BadRequest()); } db.Entry(sede).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!sedeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(long id) { sede sede = db.sede.Find(id); db.sede.Remove(sede); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteSede(int id, int idempresa) { sede se = db.sedes.Find(id); db.sedes.Remove(se); db.SaveChanges(); var sedes = db.sedes.Include(u => u.usuario).Include(e => e.empresa).Where(x => x.idempresa == idempresa); return(PartialView("ListSede", sedes.ToList())); }
public ActionResult Sede(sede sede) { if (ModelState.IsValid) { db.sedes.Add(sede); db.SaveChanges(); return(PartialView("List", db.empresas.ToList())); } return(PartialView("List", db.empresas.ToList())); }
public async Task <IHttpActionResult> Getsede(int id) { sede sede = await db.sede.FindAsync(id); if (sede == null) { return(NotFound()); } return(Ok(sede)); }
public ActionResult Edit([Bind(Include = "ID_Sede,Nombre_Sede,Direccion_Sede,Telefono,ID_Centro,Estado_sede,FechaDeCreacion_Sede,FechaDeInactivacion_Sede")] sede sede) { if (ModelState.IsValid) { db.Entry(sede).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_Centro = new SelectList(db.centro_formacion, "ID_Centro", "Nombre_Centro", sede.ID_Centro); return(View(sede)); }
public async Task <IHttpActionResult> Postsede(sede sede) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.sede.Add(sede); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = sede.id }, sede)); }
public async Task <IHttpActionResult> Deletesede(int id) { sede sede = await db.sede.FindAsync(id); if (sede == null) { return(NotFound()); } db.sede.Remove(sede); await db.SaveChangesAsync(); return(Ok(sede)); }
// GET: sede/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } sede sede = db.sede.Find(id); if (sede == null) { return(HttpNotFound()); } return(View(sede)); }
// GET: sede/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } sede sede = db.sede.Find(id); if (sede == null) { return(HttpNotFound()); } ViewBag.ID_Centro = new SelectList(db.centro_formacion, "ID_Centro", "Nombre_Centro", sede.ID_Centro); return(View(sede)); }
public async Task <IHttpActionResult> Deletesede(int idComplejo) { //JObject o = JObject.Parse(body); //int id = (int) o["idComplejo"]; sede sede = db.sedes.FirstOrDefault(x => x.idSEDE == idComplejo); if (sede == null) { return(NotFound()); } db.sedes.Remove(sede); await db.SaveChangesAsync(); return(Ok(sede)); }
public async Task <IHttpActionResult> Putsede(string body) { JObject o = JObject.Parse(body); int idComplejo = (int)o["idComplejo"]; sede Sede = new sede(); try { Sede.idSEDE = (int)o["idComplejo"]; Sede.Nombre = (string)o["nombre"]; Sede.ciudad = (string)o["ciudad"]; Sede.calle = (string)o["calle"]; Sede.avenida = (string)o["avenida"]; Sede.lat = (decimal)o["latitud"]; Sede.lng = (decimal)o["longitud"]; Sede.email = (string)o["email"]; } catch (Exception e) { return(BadRequest(ModelState)); } if (idComplejo != Sede.idSEDE) { return(BadRequest()); } db.Entry(Sede).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!sedeExists(idComplejo)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.Accepted)); }
public async Task <IHttpActionResult> Postsede(string body) { JObject o = JObject.Parse(body); sede Sede = new sede(); try { //Sede.idSEDE = (int)o["idComplejo"]; Sede.Nombre = (string)o["nombre"]; Sede.ciudad = (string)o["ciudad"]; Sede.calle = (string)o["calle"]; Sede.avenida = (string)o["avenida"]; Sede.lat = (decimal)o["latitud"]; Sede.lng = (decimal)o["longitud"]; Sede.email = (string)o["email"]; } catch (Exception e) { return(BadRequest(ModelState)); } db.sedes.Add(Sede); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (sedeExists(Sede.idSEDE)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = Sede.idSEDE }, Sede)); }
public void RegistrarSede(sede sed) { context.sede.ToList(); context.SaveChanges(); }
public void RegistrarSede(sede sed) { repositorio.RegistrarSede(sed); }