Click here to Skip to main content
15,506,846 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: SSL Certificate Pin
Richard Deeming20-Sep-21 22:47
mveRichard Deeming20-Sep-21 22:47 
GeneralRe: SSL Certificate Pin
Kevin Marois21-Sep-21 5:22
professionalKevin Marois21-Sep-21 5:22 
GeneralRe: SSL Certificate Pin
Richard Deeming21-Sep-21 6:36
mveRichard Deeming21-Sep-21 6:36 
GeneralRe: SSL Certificate Pin
Kevin Marois21-Sep-21 7:02
professionalKevin Marois21-Sep-21 7:02 
GeneralRe: SSL Certificate Pin
Richard Deeming21-Sep-21 7:37
mveRichard Deeming21-Sep-21 7:37 
GeneralRe: SSL Certificate Pin
Kevin Marois21-Sep-21 7:53
professionalKevin Marois21-Sep-21 7:53 
GeneralRe: SSL Certificate Pin
SlothTheCoder29-Oct-21 16:11
professionalSlothTheCoder29-Oct-21 16:11 
QuestionAPI Controller Question Pin
Kevin Marois26-Aug-21 7:13
professionalKevin Marois26-Aug-21 7: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.

AnswerRe: API Controller Question Pin
Richard Deeming26-Aug-21 7:41
mveRichard Deeming26-Aug-21 7:41 
GeneralRe: API Controller Question Pin
Kevin Marois26-Aug-21 8:28
professionalKevin Marois26-Aug-21 8:28 
GeneralRe: API Controller Question Pin
Richard Deeming26-Aug-21 22:41
mveRichard Deeming26-Aug-21 22:41 
QuestionModal Question Pin
MekaC24-Aug-21 11:40
MekaC24-Aug-21 11:40 
Question.Net Framework Web API - Server Error Pin
Kevin Marois23-Aug-21 12:50
professionalKevin Marois23-Aug-21 12:50 
AnswerRe: .Net Framework Web API - Server Error Pin
Richard Deeming23-Aug-21 22:18
mveRichard Deeming23-Aug-21 22:18 
GeneralRe: .Net Framework Web API - Server Error Pin
Kevin Marois24-Aug-21 5:36
professionalKevin Marois24-Aug-21 5:36 
GeneralRe: .Net Framework Web API - Server Error Pin
Richard Deeming24-Aug-21 7:13
mveRichard Deeming24-Aug-21 7:13 
GeneralRe: .Net Framework Web API - Server Error Pin
Kevin Marois24-Aug-21 7:27
professionalKevin Marois24-Aug-21 7:27 
QuestionWebrequest is obselete what is the alternatieve Pin
Ger F. Versteeg27-Jul-21 0:45
Ger F. Versteeg27-Jul-21 0:45 
AnswerRe: Webrequest is obselete what is the alternatieve Pin
Richard Deeming28-Jul-21 0:57
mveRichard Deeming28-Jul-21 0:57 
GeneralRe: Webrequest is obselete what is the alternatieve Pin
Ger F. Versteeg28-Jul-21 1:58
Ger F. Versteeg28-Jul-21 1:58 
GeneralRe: Webrequest is obselete what is the alternatieve Pin
Richard Deeming28-Jul-21 4:09
mveRichard Deeming28-Jul-21 4:09 
GeneralRe: Webrequest is obselete what is the alternatieve Pin
Ger F.28-Jul-21 5:24
Ger F.28-Jul-21 5:24 
QuestionWebsite Deployment Pin
Promise Sheggs21-Jul-21 11:32
Promise Sheggs21-Jul-21 11:32 
AnswerRe: Website Deployment Pin
Member 150787164-Jul-22 19:53
Member 150787164-Jul-22 19:53 
QuestionHow to place text over an image using HTML/CSS? Pin
Alex Dunlop21-Jul-21 8:52
Alex Dunlop21-Jul-21 8:52 

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.