public HttpResponseMessage SaveDepartamentos([FromBody] Departamentos Dep) { bool SuccessfullSaved = DepartamentosHelper.Save(Dep); if (!SuccessfullSaved) { throw new HttpResponseException(HttpStatusCode.InternalServerError); } return(Request.CreateResponse(HttpStatusCode.Created)); }
public HttpResponseMessage GetAllDepartamentos() { List <Departamentos> list = DepartamentosHelper.GetAll(); bool TheresData = list.Count > 0; if (!TheresData) { throw new HttpResponseException(HttpStatusCode.NoContent); } return(Request.CreateResponse(HttpStatusCode.OK, list)); }
protected void btnIngresar_Click(object sender, EventArgs e) { if (radioActivo.Checked) { try { this.dp = new Departamentos(); this.dp.Descripcion = this.txtdepartamento.Text; this.dp.Estado = 1; this.dp.Opc = 1; this.dpH = new DepartamentosHelper(dp); this.dpH.IngresarDepartamentos(); ScriptManager.RegisterStartupScript(this, typeof(Page), "mensajeDeconfirmacion", "mensajeDeconfirmacion('" + "" + "');", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, typeof(Page), "mensajeError", "mensajeError('" + "" + "');", true); } } else if (radioInactivo.Checked) { try { this.dp = new Departamentos(); this.dp.Descripcion = this.txtdepartamento.Text; this.dp.Estado = 2; this.dp.Opc = 1; this.dpH = new DepartamentosHelper(dp); this.dpH.IngresarDepartamentos(); ScriptManager.RegisterStartupScript(this, typeof(Page), "mensajeDeconfirmacion", "mensajeDeconfirmacion('" + "" + "');", true); } catch (Exception) { ScriptManager.RegisterStartupScript(this, typeof(Page), "mensajeError", "mensajeError('" + "" + "');", true); } } }