public void GetCustomer(Int64 customerID) { //List<CustomerBAL> lst = new List<CustomerBAL>(); DataTable dt = new DataTable(); CustomerBAL obj = new CustomerBAL(); dt = obj.GetCustomer(customerID); obj = null; if (dt.Rows.Count > 0) { divResult.Attributes.Add("class", "show"); divNoRecord.Attributes.Add("class", "hide"); hdnCustomerID.Value = dt.Rows[0]["CustomerID"].ToString(); lblFirstName.Text = dt.Rows[0]["FirstName"].ToString(); lblLastName.Text = dt.Rows[0]["LastName"].ToString(); lblBirthDate.Text = Convert.ToDateTime(dt.Rows[0]["BirthDate"]).ToShortDateString(); lblEmail.Text = dt.Rows[0]["Email"].ToString(); lblAddress.Text = dt.Rows[0]["Address"].ToString(); } else { divResult.Attributes.Add("class", "hide"); divNoRecord.Attributes.Add("class", "show"); } }
public IActionResult GetCustomer(int id) { try { return(new JsonResult(CustomerBAL.GetCustomer(id))); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to get Customer")); } }
public ActionResult MyFirstViewMethod() { CustomerBAL b = new CustomerBAL(); Customer c = b.GetCustomer(); //string cadena = "Data Source=Desarrollo; Initial Catalog =pruebas; User ID=sa;Password=sa"; //SqlConnection conectarBD = new SqlConnection(); //conectarBD.ConnectionString = cadena; //conectarBD.Open(); //conexionBD conBD = new conexionBD(); //conBD.abrir(); //SqlCommand com = new SqlCommand("select * from cliente", conBD.conectarBD); //listaUsuarios = com.ExecuteScalar(); // var usuario = listaUsuarios.FirstOrDefault(f => f.Nombre == "Prodensa"); DataBasepruebas conbd = new DataBasepruebas(); var listaClientes = (from d in conbd.Cliente select new ListaCliente { IdCliente = d.IdCliente, Numero = d.Numero, Nombre = d.Nombre } ).ToList(); //var listaClientes = conbd.Cliente.ToList(); //var Cliente = conbd.Cliente.FirstOrDefault(f => f.Nombre == "Prodensa"); //return new JsonResult //{ // JsonRequestBehavior = JsonRequestBehavior.AllowGet, // //Data = listaClientes // Data = Cliente //}; //var count = (int)com.ExecuteScalar(); //ViewData["TotalData"] = count; //string CustomerName = "Mr ABC."; ////ViewData["MyData"] = CustomerName; //ViewBag.MyData = "CustomerName"; //ViewBag.CustomerData = c; //conBD.cerrar(); //conectarBD.Close(); return(View("MyFirstView", listaClientes)); }
private void GetCustomer() { List <Customer> customers = CustomerBAL.GetCustomer(Request.QueryString); if ((customers != null) && customers.Count > 0) { Response.Write(customers.ToJSON()); } else { Response.Write("No Result"); } }
public ActionResult MyFirstView() { CustomerBAL b = new CustomerBAL(); Customer c = b.GetCustomer(); ViewBag.CustomerData = c; //string CustomerName = "Mr. ABC"; //ViewData["MyData"] = CustomerName; ////ViewBag.MyData = CustomerName; //return View("MyFirstView"); return(View()); }
public void BindGrid() { //List<CustomerBAL> lst = new List<CustomerBAL>(); DataTable dt = new DataTable(); CustomerBAL obj = new CustomerBAL(); dt = obj.GetCustomer(0); obj = null; if (dt.Rows.Count > 0) { divGrid.Visible = true; divNoRecords.Visible = false; grdCustomer.DataSource = dt; grdCustomer.DataBind(); } else { divGrid.Visible = false; divNoRecords.Visible = true; } }
public HttpResponseMessage GetCustomer([FromBody] CustomerRequestDTO inputParam) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "Not found"); try { ICustomerBAL customerBAL = new CustomerBAL(); switch (customerBAL.ValidateRequest(inputParam)) { case ValidationStatus.Success: var output = customerBAL.GetCustomer(inputParam); if (output != null) { response = Request.CreateResponse(HttpStatusCode.OK, output); } break; case ValidationStatus.BadRequest: response = Request.CreateResponse(HttpStatusCode.BadRequest, ""); break; case ValidationStatus.InvalidCustomerId: response = Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid Customer Id"); break; case ValidationStatus.InvalidEmail: response = Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid Email"); break; case ValidationStatus.NoInquiryCriteria: response = Request.CreateResponse(HttpStatusCode.BadRequest, "No inquiry criteria"); break; } } catch (Exception) { response = Request.CreateResponse(HttpStatusCode.BadRequest, ""); } return(response); }