Click here to Skip to main content
15,913,090 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: Tip to build perfect mobile application Pin
megaadam18-Oct-21 5:11
professionalmegaadam18-Oct-21 5:11 
QuestionASP.Net Core Web API Exception - Can't Find System.Data.Linq Pin
Kevin Marois11-Oct-21 6:40
professionalKevin Marois11-Oct-21 6:40 
AnswerRe: ASP.Net Core Web API Exception - Can't Find System.Data.Linq Pin
Dave Kreskowiak11-Oct-21 8:01
mveDave Kreskowiak11-Oct-21 8:01 
GeneralRe: ASP.Net Core Web API Exception - Can't Find System.Data.Linq Pin
Kevin Marois11-Oct-21 8:33
professionalKevin Marois11-Oct-21 8:33 
GeneralRe: ASP.Net Core Web API Exception - Can't Find System.Data.Linq Pin
#realJSOP2-Nov-21 0:43
professional#realJSOP2-Nov-21 0:43 
GeneralRe: ASP.Net Core Web API Exception - Can't Find System.Data.Linq Pin
Richard Deeming2-Nov-21 1:14
mveRichard Deeming2-Nov-21 1:14 
GeneralRe: ASP.Net Core Web API Exception - Can't Find System.Data.Linq Pin
Kevin Marois2-Nov-21 4:34
professionalKevin Marois2-Nov-21 4:34 
AnswerRe: ASP.Net Core Web API Exception - Can't Find System.Data.Linq Pin
Richard Deeming11-Oct-21 22:11
mveRichard Deeming11-Oct-21 22:11 
GeneralRe: ASP.Net Core Web API Exception - Can't Find System.Data.Linq Pin
Kevin Marois12-Oct-21 7:34
professionalKevin Marois12-Oct-21 7:34 
GeneralRe: ASP.Net Core Web API Exception - Can't Find System.Data.Linq Pin
#realJSOP2-Nov-21 1:01
professional#realJSOP2-Nov-21 1:01 
QuestionSecuring A Web API Pin
Kevin Marois20-Sep-21 11:51
professionalKevin Marois20-Sep-21 11:51 
AnswerRe: Securing A Web API Pin
#realJSOP2-Nov-21 1:06
professional#realJSOP2-Nov-21 1:06 
GeneralRe: Securing A Web API Pin
Kevin Marois2-Nov-21 4:35
professionalKevin Marois2-Nov-21 4:35 
QuestionLaravel 8 how to add elements to navbar app.blade Pin
paradox0215-Sep-21 2:01
paradox0215-Sep-21 2:01 
QuestionSSL Certificate Pin
Kevin Marois26-Aug-21 7:23
professionalKevin Marois26-Aug-21 7:23 
AnswerRe: SSL Certificate Pin
Richard Deeming26-Aug-21 21:52
mveRichard Deeming26-Aug-21 21:52 
GeneralRe: SSL Certificate Pin
Kevin Marois20-Sep-21 9:23
professionalKevin Marois20-Sep-21 9:23 
GeneralRe: SSL Certificate Pin
Richard Deeming20-Sep-21 21:47
mveRichard Deeming20-Sep-21 21:47 
GeneralRe: SSL Certificate Pin
Kevin Marois21-Sep-21 4:22
professionalKevin Marois21-Sep-21 4:22 
GeneralRe: SSL Certificate Pin
Richard Deeming21-Sep-21 5:36
mveRichard Deeming21-Sep-21 5:36 
GeneralRe: SSL Certificate Pin
Kevin Marois21-Sep-21 6:02
professionalKevin Marois21-Sep-21 6:02 
GeneralRe: SSL Certificate Pin
Richard Deeming21-Sep-21 6:37
mveRichard Deeming21-Sep-21 6:37 
GeneralRe: SSL Certificate Pin
Kevin Marois21-Sep-21 6:53
professionalKevin Marois21-Sep-21 6:53 
GeneralRe: SSL Certificate Pin
SlothTheCoder29-Oct-21 15:11
professionalSlothTheCoder29-Oct-21 15:11 
QuestionAPI Controller Question Pin
Kevin Marois26-Aug-21 6:13
professionalKevin Marois26-Aug-21 6:13 
I'm working on setting up a .Net Framework Web API. I have created a Controller Base class:
public class _ApiControllerBase : ApiController
{
    private string connectionString;

    public IBizLayer BL { get; set; }

    public _ApiControllerBase()
    {
        connectionString = Properties.Settings.Default.ConnectionString;
        BL = new BizLayer(connectionString);
    }
}
Next I created a Jobs Controller:
public class JobsController : _ApiControllerBase
{
    public int AddJob([FromBody] JobEntity entity)
    {
        var newJobId = BL.AddJob(entity);
        return newJobId;
    }

    public void DeleteJob(int jobId)
    {
        BL.DeleteJob(jobId);
    }

    public IEnumerable GetAllJobs()
    {
        List results = new List();
        results = BL.GetJobsForProject(278).ToList();

        return results;
    }

    public JobEntity GetJob(int Job)
    {
        return BL.GetJob(Job);
    }

    public List GetJobsForProject(int projectId)
    {
        List results = new List();
        results = BL.GetJobsForProject(projectId).ToList();

        return results;
    }

    public void UpdateJob([FromBody] JobEntity entity)
    {
        BL.UpdateJob(entity);
    }
}
and my WebApiConfig:
public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
    }
}
I have tested all of this with Postman and it seems to work OK.

Any reason not to structure all my controllers this way? Any issues or problems I should be aware of?

Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.