Partial view macro parameters and surface controllers
The basis of what I am trying to achieve is to allow a macro to be inserted into a RTE with a parameter of employeeID. This will connect to a 3rd party database and pull the employee details from that database and render them within the copy of the Rich text editor. I have managed to connect and render the details into a view using MVC outside of Umbraco but I am having trouble getting my code to work within Umbraco.
I started with using LINQ to SQL Classes to create my model EmployeeDetailsDataContext within visual Studio using a view within my database called vwPeopleProfiles.
I then created my surface Controller EmployeeDetailsSurfaceController as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Test.Models;
using Umbraco.Web.Mvc
namespace Test.Controllers
{
public class EmployeeController : SurfaceController
{
public ActionResult Details(string id)
{
var dataContext = new EmployeeDetailsDataContext();
var employee = (from e in dataContext.vwPeople_Profiles
where e.Employee_ID == id
select e).First();
return View(employee);
}
}
}
This code was copied from my normal controller and the return references a details view but I don't know the correct syntax for return to reference a Macro.
I have created a Partial View Macro File within Umbraco but was not sure how to call the SurfaceController and then render the results onto the page:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@if (Model.MacroParameters["employeeID"] != null)
{
//do something here to take the 'employeeID' macro parameter and pass it in to the 'Details' Action within the 'EmployeeDetailsSurfaceController' Surface controller
}
All the examples I can find on the net focus around form submitting with Macros and surface controllers and although I think I could be close to resolving this issue I am stuck, can anybody help?
I could not get that to work. Perhaps I should start at the beginning and ask what is the best way to just read (don't need to create, update or delete) a single record of data from a 3rd party database (not the database used for Umbraco)?
Would it be LINQ to SQL Classes or PetaPoco, then I can try to get my head around the best method of displaying this data
Partial view macro parameters and surface controllers
The basis of what I am trying to achieve is to allow a macro to be inserted into a RTE with a parameter of employeeID. This will connect to a 3rd party database and pull the employee details from that database and render them within the copy of the Rich text editor. I have managed to connect and render the details into a view using MVC outside of Umbraco but I am having trouble getting my code to work within Umbraco.
I started with using LINQ to SQL Classes to create my model EmployeeDetailsDataContext within visual Studio using a view within my database called vwPeopleProfiles.
I then created my surface Controller EmployeeDetailsSurfaceController as follows:
This code was copied from my normal controller and the return references a details view but I don't know the correct syntax for return to reference a Macro.
I have created a Partial View Macro File within Umbraco but was not sure how to call the SurfaceController and then render the results onto the page:
All the examples I can find on the net focus around form submitting with Macros and surface controllers and although I think I could be close to resolving this issue I am stuck, can anybody help?
Try returning as a partial view with a model and check ,
return PartialView("Employee", new EmpModel());
I could not get that to work. Perhaps I should start at the beginning and ask what is the best way to just read (don't need to create, update or delete) a single record of data from a 3rd party database (not the database used for Umbraco)?
Would it be LINQ to SQL Classes or PetaPoco, then I can try to get my head around the best method of displaying this data
is working on a reply...