Line | |
---|
1 | using Dal.ApplicationStorage.DataAccess.Abstract;
|
---|
2 | using Microsoft.AspNetCore.Http;
|
---|
3 | using Microsoft.AspNetCore.Mvc;
|
---|
4 | using Microsoft.AspNetCore.Mvc.ModelBinding;
|
---|
5 | using Models.DataTransferObjects.Company;
|
---|
6 |
|
---|
7 | namespace ocrent.Controllers
|
---|
8 | {
|
---|
9 | public class CompanyController : Controller
|
---|
10 | {
|
---|
11 | private readonly ICompanyDa _companyDa;
|
---|
12 | public CompanyController(ICompanyDa companyDa)
|
---|
13 | {
|
---|
14 | _companyDa = companyDa;
|
---|
15 | }
|
---|
16 |
|
---|
17 | public async Task<IActionResult> IndexAsync()
|
---|
18 | {
|
---|
19 | var userId = HttpContext.Session.GetString("userId");
|
---|
20 | var companies = await _companyDa.GetUserCompanies(Int32.Parse(userId));
|
---|
21 |
|
---|
22 | return View(companies);
|
---|
23 | }
|
---|
24 |
|
---|
25 | public IActionResult RegisterCompany()
|
---|
26 | {
|
---|
27 | var email = HttpContext.Session.GetString("email");
|
---|
28 | ViewBag.UserEmail = email;
|
---|
29 | return View();
|
---|
30 | }
|
---|
31 |
|
---|
32 | [HttpPost]
|
---|
33 | public IActionResult RegisterCompany(RegisterCompanyDTO companyDTO)
|
---|
34 | {
|
---|
35 | if (companyDTO.CompanyEmail != null && companyDTO.CompanyName != null)
|
---|
36 | {
|
---|
37 | companyDTO.CreatedBy = Int32.Parse(HttpContext.Session.GetString("userId"));
|
---|
38 | _companyDa.AddCompany(companyDTO);
|
---|
39 | return Json(Url.Action("Index", "Company"));
|
---|
40 | }
|
---|
41 | return View();
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
45 | }
|
---|
46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.