-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cpa mvc functionality (seperate project called cpamvc)
- Loading branch information
Showing
96 changed files
with
25,600 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace cpa.Controllers | ||
{ | ||
public class StatementsController : Controller | ||
{ | ||
// GET: Statements | ||
public ActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
// GET: Statements/Details/5 | ||
public ActionResult Details(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// GET: Statements/Create | ||
public ActionResult Create() | ||
{ | ||
return View(); | ||
} | ||
|
||
// POST: Statements/Create | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public ActionResult Create(IFormCollection collection) | ||
{ | ||
try | ||
{ | ||
// TODO: Add insert logic here | ||
|
||
return RedirectToAction(nameof(Index)); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
|
||
// GET: Statements/Edit/5 | ||
public ActionResult Edit(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// POST: Statements/Edit/5 | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public ActionResult Edit(int id, IFormCollection collection) | ||
{ | ||
try | ||
{ | ||
// TODO: Add update logic here | ||
|
||
return RedirectToAction(nameof(Index)); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
|
||
// GET: Statements/Delete/5 | ||
public ActionResult Delete(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// POST: Statements/Delete/5 | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public ActionResult Delete(int id, IFormCollection collection) | ||
{ | ||
try | ||
{ | ||
// TODO: Add delete logic here | ||
|
||
return RedirectToAction(nameof(Index)); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Scaffolding has generated all the files and added the required dependencies. | ||
|
||
However the Application's Startup code may required additional changes for things to work end to end. | ||
Add the following code to the Configure method in your Application's Startup class if not already done: | ||
|
||
app.UseMvc(routes => | ||
{ | ||
route.MapRoute( | ||
name : "areas", | ||
template : "{area:exists}/{controller=Home}/{action=Index}/{id?}" | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
@{ | ||
ViewData["Title"] = "Index"; | ||
} | ||
|
||
<h2>Index</h2> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 | ||
|
||
namespace cpamvc.Controllers | ||
{ | ||
public class AddSourceController : Controller | ||
{ | ||
// GET: /<controller>/ | ||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 | ||
|
||
namespace cpamvc.Controllers | ||
{ | ||
public class AnalysisController : Controller | ||
{ | ||
// GET: /<controller>/ | ||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Linq; | ||
using cpamvc.Models; | ||
|
||
namespace cpamvc.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
public class ArticleController : Controller | ||
{ | ||
[HttpGet] | ||
public IEnumerable<Article> GetArticles() | ||
{ | ||
//return array of article objects | ||
|
||
return null; | ||
} | ||
|
||
[HttpGet("{id}")] | ||
public IActionResult GetArticleById(long id) | ||
{ | ||
//retrieve individual article by an id | ||
return null; | ||
} | ||
[HttpGet("/company/{id}")] | ||
public IActionResult GetArticleByCompany(long id) | ||
{ | ||
//retrieve individual article by a Company id | ||
return null; | ||
} | ||
[HttpGet("/company/{companyID}/ratio/{ratioID}")] | ||
public IActionResult GetRelevantArticles(long companyID, long ratioID) | ||
{ | ||
//retrieve articles by company + ratio | ||
return null; | ||
} | ||
|
||
[HttpPost] | ||
public IActionResult AddArticle([FromBody] Article article) | ||
{ | ||
if (article == null) { | ||
return BadRequest(); | ||
} | ||
//post article | ||
return null; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Linq; | ||
using cpamvc.Models; | ||
using System.Data.SqlClient; | ||
using System; | ||
using System.Data; | ||
|
||
namespace cpamvc.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
public class CompanyController : Controller | ||
{ | ||
SqlConnection sqlConn = new SqlConnection("Server=localhost;Database=cpa;Trusted_Connection=True;"); | ||
|
||
[HttpGet] | ||
public IEnumerable<Company> GetCompanies() | ||
{ | ||
//return array of company objects | ||
|
||
List<Company> companies = new List<Company>(); | ||
|
||
try | ||
{ | ||
sqlConn.Open(); | ||
SqlDataReader myReader = null; | ||
SqlCommand sqlCmd = new SqlCommand("SELECT id, name, description, market, symbol FROM company", sqlConn); | ||
|
||
myReader = sqlCmd.ExecuteReader(); | ||
while (myReader.Read()) | ||
{ | ||
companies.Add(new Company(Int32.Parse(myReader["id"].ToString()), myReader["name"].ToString(), | ||
myReader["description"].ToString(), myReader["market"].ToString(), myReader["symbol"].ToString())); | ||
} | ||
|
||
sqlConn.Close(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.ToString()); | ||
} | ||
|
||
//testing -- it works on route /api/company | ||
//Company c1 = new Company(1, "Apple"); | ||
//Company c2 = new Company(2, "IBM"); | ||
//Company c3 = new Company(3, "Amazon"); | ||
|
||
//companies.Add(c1); | ||
//companies.Add(c2); | ||
//companies.Add(c3); | ||
return companies; | ||
} | ||
|
||
[HttpGet("{id}")] | ||
public IActionResult GetCompanyById(int id) | ||
{ | ||
//retrieve individual company by an id | ||
|
||
Company company = null; | ||
|
||
try | ||
{ | ||
sqlConn.Open(); | ||
SqlDataReader myReader = null; | ||
SqlCommand sqlCmd = new SqlCommand("SELECT TOP 1 id, name, description, market, symbol FROM company WHERE id = @Param1", sqlConn); | ||
sqlCmd.Parameters.Add(new SqlParameter("@Param1", SqlDbType.Int) { Value = id }); | ||
|
||
myReader = sqlCmd.ExecuteReader(); | ||
while (myReader.Read()) | ||
{ | ||
company = new Company(Int32.Parse(myReader["id"].ToString()), myReader["name"].ToString(), | ||
myReader["description"].ToString(), myReader["market"].ToString(), myReader["symbol"].ToString()); | ||
} | ||
|
||
sqlConn.Close(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.ToString()); | ||
} | ||
|
||
return new ObjectResult(company); | ||
} | ||
|
||
[HttpPost] | ||
public IActionResult AddCompany([FromBody] Company company) | ||
{ | ||
if (company == null) | ||
{ | ||
return BadRequest(); | ||
} | ||
|
||
//post company | ||
return null; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using cpamvc.Models; | ||
|
||
namespace cpamvc.Controllers | ||
{ | ||
public class HomeController : Controller | ||
{ | ||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
public IActionResult About() | ||
{ | ||
ViewData["Message"] = "Your application description page."; | ||
|
||
return View(); | ||
} | ||
|
||
public IActionResult Contact() | ||
{ | ||
ViewData["Message"] = "Your contact page."; | ||
|
||
return View(); | ||
} | ||
|
||
public IActionResult Error() | ||
{ | ||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); | ||
} | ||
} | ||
} |
Empty file.
Oops, something went wrong.