source: Application/ocrent/Controllers/CompanyController.cs@ f5f7c24

Last change on this file since f5f7c24 was f5f7c24, checked in by 192011 <mk.snicker@…>, 17 months ago

Initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1using Dal.ApplicationStorage.DataAccess.Abstract;
2using Microsoft.AspNetCore.Http;
3using Microsoft.AspNetCore.Mvc;
4using Microsoft.AspNetCore.Mvc.ModelBinding;
5using Models.DataTransferObjects.Company;
6
7namespace 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.