1 | @model Models.DataTransferObjects.Company.RegisterCompanyDTO
|
---|
2 |
|
---|
3 | @{
|
---|
4 | ViewData["Title"] = "Register Company Page";
|
---|
5 | }
|
---|
6 |
|
---|
7 | <div class="container py-5 text-light business-acc">
|
---|
8 | <h3 class="mb-5">Register your rent-a-car company</h3>
|
---|
9 | <form method="post" asp-action="RegisterCompany" asp-controller="Company">
|
---|
10 | <div class="form-group">
|
---|
11 | <label for="company-name" class="form-label" asp-for="CompanyName">
|
---|
12 | Company name
|
---|
13 | </label>
|
---|
14 | <input type="text" asp-for="CompanyName"
|
---|
15 | id="company-name"
|
---|
16 | class="form-control"
|
---|
17 | autocomplete="off"
|
---|
18 | required />
|
---|
19 | </div>
|
---|
20 | <div class="form-group">
|
---|
21 | <label for="company-email" class="form-label" asp-for="CompanyEmail">
|
---|
22 | Company Email
|
---|
23 | </label>
|
---|
24 | <input type="email" asp-for="CompanyEmail"
|
---|
25 | id="company-email"
|
---|
26 | class="form-control"
|
---|
27 | autocomplete="off"
|
---|
28 | required />
|
---|
29 | </div>
|
---|
30 | <div class="form-group">
|
---|
31 | <label for="company-owner" class="form-label">
|
---|
32 | Owner
|
---|
33 | </label>
|
---|
34 | <input type="text"
|
---|
35 | id="company-owner"
|
---|
36 | class="form-control"
|
---|
37 | autocomplete="off"
|
---|
38 | value="@ViewBag.UserEmail"
|
---|
39 | readonly />
|
---|
40 | </div>
|
---|
41 | <div class="form-group d-flex align-items-end">
|
---|
42 | <input id="submit"
|
---|
43 | class="btn btn-success"
|
---|
44 | value="Submit" />
|
---|
45 | </div>
|
---|
46 | </form>
|
---|
47 | </div>
|
---|
48 |
|
---|
49 | <style>
|
---|
50 | .business-acc {
|
---|
51 | min-height: calc(100vh - 100px);
|
---|
52 | }
|
---|
53 |
|
---|
54 | .business-acc form {
|
---|
55 | display: grid;
|
---|
56 | grid-template-columns: 1fr 1fr;
|
---|
57 | gap: 25px;
|
---|
58 | }
|
---|
59 | </style>
|
---|
60 |
|
---|
61 | @section Scripts{
|
---|
62 | <script>
|
---|
63 | $(document).ready(function(){
|
---|
64 | var token = $("input[name='__RequestVerificationToken']").val();
|
---|
65 |
|
---|
66 | $('#submit').on("click", function () {
|
---|
67 | var companyDTO = {};
|
---|
68 | companyDTO.CompanyName = $('#company-name').val();
|
---|
69 | companyDTO.CompanyEmail = $('#company-email').val();
|
---|
70 |
|
---|
71 | if (companyDTO.CompanyName != "" && companyDTO.CompanyEmail != ""){
|
---|
72 | Swal.fire({
|
---|
73 | title: 'Are you sure?',
|
---|
74 | text: "Are you sure that you want to sent an application for company registration?",
|
---|
75 | icon: 'warning',
|
---|
76 | showCancelButton: true,
|
---|
77 | confirmButtonColor: '#3085d6',
|
---|
78 | cancelButtonColor: '#d33',
|
---|
79 | confirmButtonText: 'Yes, submit!'
|
---|
80 | }).then((result) => {
|
---|
81 | if (result.isConfirmed) {
|
---|
82 | const Toast = Swal.mixin({
|
---|
83 | toast: true,
|
---|
84 | position: 'top-end',
|
---|
85 | showConfirmButton: false,
|
---|
86 | timer: 3000,
|
---|
87 | timerProgressBar: true,
|
---|
88 | didOpen: (toast) => {
|
---|
89 | toast.addEventListener('mouseenter', Swal.stopTimer)
|
---|
90 | toast.addEventListener('mouseleave', Swal.resumeTimer)
|
---|
91 | }
|
---|
92 | })
|
---|
93 |
|
---|
94 | Toast.fire({
|
---|
95 | icon: 'success',
|
---|
96 | title: 'Application successfully submitted'
|
---|
97 | })
|
---|
98 |
|
---|
99 | $.ajax({
|
---|
100 | type: "POST",
|
---|
101 | headers:
|
---|
102 | {
|
---|
103 | "RequestVerificationToken": token
|
---|
104 | },
|
---|
105 | url: "@Url.Action("RegisterCompany","Company")",
|
---|
106 | data: {
|
---|
107 | companyDTO: companyDTO,
|
---|
108 | },
|
---|
109 | success: function (data) {
|
---|
110 | window.location.href = data;
|
---|
111 | },
|
---|
112 | error: function (req, status, error) {
|
---|
113 | }
|
---|
114 | })
|
---|
115 |
|
---|
116 |
|
---|
117 | }
|
---|
118 | })
|
---|
119 | }else{
|
---|
120 | const Toast = Swal.mixin({
|
---|
121 | toast: true,
|
---|
122 | position: 'top-end',
|
---|
123 | showConfirmButton: false,
|
---|
124 | timer: 3000,
|
---|
125 | timerProgressBar: true,
|
---|
126 | didOpen: (toast) => {
|
---|
127 | toast.addEventListener('mouseenter', Swal.stopTimer)
|
---|
128 | toast.addEventListener('mouseleave', Swal.resumeTimer)
|
---|
129 | }
|
---|
130 | })
|
---|
131 |
|
---|
132 | Toast.fire({
|
---|
133 | icon: 'error',
|
---|
134 | title: 'Both fields are required!'
|
---|
135 | })
|
---|
136 | }
|
---|
137 |
|
---|
138 |
|
---|
139 | })
|
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 | })
|
---|
145 | </script>
|
---|
146 | } |
---|