Skip to main content
Bumped by Community user
Tweeted twitter.com/StackCodeReview/status/1149060854656225281
Bumped by Community user
edited tags
Link
prinkpan
  • 201
  • 2
  • 9
added 14 characters in body
Source Link
prinkpan
  • 201
  • 2
  • 9

We use the following architecture shown in the code below to initialize the DB context for our MVC 5 project using entity framework 6

We use the following architecture to initialize the DB context for our MVC 5 project using entity framework 6

We use the architecture shown in the code below to initialize the DB context for our MVC 5 project using entity framework 6

added 4 characters in body
Source Link
prinkpan
  • 201
  • 2
  • 9
[HttpPost]
public async Task<ContentResult> Perform(string operation, string entity, FormCollection form = null)
{
    var json = string.Empty;
    var returnTuple = new Tuple<string, int, string>(string.Empty, (int)HttpStatusCode.InternalServerError, "Default return value");
    
    switch (operation)
    {
        case "GET":
            switch (entity)
            {
                case ("ALLSCHOOLS"):
                    returnTuple = await GetSchools(form);
                break;
                
                ...
            }
        break;
        
        case "POST":
            switch (entity)
            {
                case "SCHOOL":
                    returnTuple = await SaveSchool(form);
                break;
                
                ...
            }
        break;
    }
    
    ...
    
    if (!string.IsNullOrEmpty(returnTuple.Item1))
    {
        json = returnTuple.Item1;
        Response.StatusCode = (int)HttpStatusCode.OK;
    }
    else
    {
        Response.StatusCode = returnTuple.Item2;
        Response.StatusDescription = returnTuple.Item3;
    }
    return Content(json, "application/json");
}
[HttpPost]
public async Task<ContentResult> Perform(string operation, string entity, FormCollection form = null)
{
    var json = string.Empty;
    var returnTuple = new Tuple<string, int, string>(string.Empty, (int)HttpStatusCode.InternalServerError, "Default return value");
    
    switch (operation)
    {
        case "GET":
            switch (entity)
            {
                case ("ALLSCHOOLS"):
                    returnTuple = await GetSchools();
                break;
                
                ...
            }
        break;
        
        case "POST":
            switch (entity)
            {
                case "SCHOOL":
                    returnTuple = await SaveSchool(form);
                break;
                
                ...
            }
        break;
    }
    
    ...
    
    if (!string.IsNullOrEmpty(returnTuple.Item1))
    {
        json = returnTuple.Item1;
        Response.StatusCode = (int)HttpStatusCode.OK;
    }
    else
    {
        Response.StatusCode = returnTuple.Item2;
        Response.StatusDescription = returnTuple.Item3;
    }
    return Content(json, "application/json");
}
[HttpPost]
public async Task<ContentResult> Perform(string operation, string entity, FormCollection form = null)
{
    var json = string.Empty;
    var returnTuple = new Tuple<string, int, string>(string.Empty, (int)HttpStatusCode.InternalServerError, "Default return value");
    
    switch (operation)
    {
        case "GET":
            switch (entity)
            {
                case ("ALLSCHOOLS"):
                    returnTuple = await GetSchools(form);
                break;
                
                ...
            }
        break;
        
        case "POST":
            switch (entity)
            {
                case "SCHOOL":
                    returnTuple = await SaveSchool(form);
                break;
                
                ...
            }
        break;
    }
    
    ...
    
    if (!string.IsNullOrEmpty(returnTuple.Item1))
    {
        json = returnTuple.Item1;
        Response.StatusCode = (int)HttpStatusCode.OK;
    }
    else
    {
        Response.StatusCode = returnTuple.Item2;
        Response.StatusDescription = returnTuple.Item3;
    }
    return Content(json, "application/json");
}
added 49 characters in body
Source Link
prinkpan
  • 201
  • 2
  • 9
Loading
Source Link
prinkpan
  • 201
  • 2
  • 9
Loading