Hi good morning, I wonder if some could guide me on how to solve a problem.
I have a site in umbraco 7.1.4 and have the need to connect to an external database not to umbraco, and display data from that database datos.He tried to do this using a control surface and entity framwork but I could not access the path or url controller surface. I would like to give a guide to how I could resolve this issue.
Thank you very much.
My Control surface
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SurfacceConBD.Models;
namespace SurfacceConBD.Controllers
{
public class PersonasSurfaceController : Umbraco.Web.Mvc.SurfaceController
{
private DataModelPersonasEntities db = new DataModelPersonasEntities();
//
// GET: /Personas/
public ActionResult Index()
{
return View(db.personas.ToList());
}
//
// GET: /Personas/Details/5
public ActionResult Details(string id = null)
{
personas personas = db.personas.Find(id);
if (personas == null)
{
return HttpNotFound();
}
return View(personas);
}
//
// GET: /Personas/Create
public ActionResult Create()
{
return View();
}
//
// POST: /Personas/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(personas personas)
{
if (ModelState.IsValid)
{
db.personas.Add(personas);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(personas);
}
//
// GET: /Personas/Edit/5
public ActionResult Edit(string id = null)
{
personas personas = db.personas.Find(id);
if (personas == null)
{
return HttpNotFound();
}
return View(personas);
}
//
// POST: /Personas/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(personas personas)
{
if (ModelState.IsValid)
{
db.Entry(personas).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(personas);
}
//
// GET: /Personas/Delete/5
public ActionResult Delete(string id = null)
{
personas personas = db.personas.Find(id);
if (personas == null)
{
return HttpNotFound();
}
return View(personas);
}
//
// POST: /Personas/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(string id)
{
personas personas = db.personas.Find(id);
db.personas.Remove(personas);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
}
Surface Control connect to database external
Hi good morning, I wonder if some could guide me on how to solve a problem. I have a site in umbraco 7.1.4 and have the need to connect to an external database not to umbraco, and display data from that database datos.He tried to do this using a control surface and entity framwork but I could not access the path or url controller surface. I would like to give a guide to how I could resolve this issue.
Thank you very much.
My Control surface
My View Index in Folder Personas/Index
is working on a reply...