Skip to content

Commit 51a8066

Browse files
committed
adding view/controller and BE controller
1 parent 8890c98 commit 51a8066

File tree

4 files changed

+123
-2
lines changed

4 files changed

+123
-2
lines changed

Diff for: Zenergy/Zenergy/Controllers/AccountController.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Threading.Tasks;
77
using System.Web;
88
using System.Web.Http;
9-
using System.Web.Http.ModelBinding;
109
using Microsoft.AspNet.Identity;
1110
using Microsoft.AspNet.Identity.EntityFramework;
1211
using Microsoft.AspNet.Identity.Owin;
@@ -19,7 +18,7 @@
1918
using Zenergy.Services;
2019
using System.Net;
2120
using Newtonsoft.Json;
22-
using System.Web.Http.Results;
21+
2322

2423
namespace Zenergy.Controllers
2524
{
@@ -504,3 +503,16 @@ public static string Generate(int strengthInBits)
504503
#endregion
505504
}
506505
}
506+
507+
508+
509+
namespace Zenergy.Controllers
510+
{
511+
public class AccountManagementController : System.Web.Mvc.Controller
512+
{
513+
public System.Web.Mvc.ActionResult Index()
514+
{
515+
return View();
516+
}
517+
}
518+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
zenergyApp.controller("accountManagementPageController", ["$scope", "$http", "$window", function ($scope, $http, $window) {
2+
3+
$scope.user = { mail: '', password: '', passwordBis: '', lastName: '', firstName: '', adr1: '', adr2: '', pc: '', town: '', phone: '' };
4+
$scope.hasError = false;
5+
$scope.passNotMatch = false;
6+
7+
$scope.changeInformations = function () {
8+
9+
if ($scope.user.password != $scope.user.passwordBis) {
10+
$scope.hasError = true;
11+
$scope.passNotMatch = true;
12+
}
13+
else {
14+
$scope.hasError = false;
15+
$scope.passNotMatch = false;
16+
}
17+
18+
if (!$scope.hasError) {
19+
var response = $http({
20+
url: '/api/Account/update',
21+
method: 'POST',
22+
data: { userId: 1, password: CryptoJS.MD5($scope.user.password).toString(), lastName: $scope.user.lastName, firstName: $scope.user.firstName, adr1: $scope.user.adr1, adr2: $scope.user.adr2, pc: $scope.user.pc, town: $scope.user.town, mail: $scope.user.mail, phone: $scope.user.phone },
23+
headers: {
24+
'Content-Type': 'application/json'
25+
}
26+
}).then(function successCallback(response) {
27+
$scope.hasError = false;
28+
window.location.replace("/home");
29+
}, function errorCallback(response) {
30+
$scope.hasError = true;
31+
$scope.user.mail = '';
32+
$scope.user.password = '';
33+
});
34+
}
35+
};
36+
}]);

Diff for: Zenergy/Zenergy/Views/AccountManagement/index.cshtml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
@{
3+
ViewBag.Title = "index";
4+
}
5+
6+
<h2>Account Management</h2>
7+
8+
<div class="container " ng-controller="accountManagementPageController">
9+
<div class="row">
10+
<div name="formInformation" class="col-md-3 col-lg-offset-4">
11+
<h1>Register</h1>
12+
<form ng-submit="changeInformations()">
13+
<!--
14+
<div class="form-group">
15+
<input type="email" class="form-control" ng-model="user.mail" placeholder="Email"required>{{user.mail}}</input>
16+
</div>
17+
-->
18+
19+
<div class="form-group">
20+
<input type="password" id="password" class="form-control" ng-model="user.password" placeholder="Password" required>{{user.password}}</input>
21+
</div>
22+
23+
<div class="form-group">
24+
<input type="password" id="passwordBis" class="form-control" ng-model="user.passwordBis" placeholder="Confirm Password" required samepassword="password">
25+
</div>
26+
<p class="text-danger" ng-if="passNotMatch">Passwords don't match</p>
27+
28+
<div class="form-group">
29+
<input type="text" class="form-control" ng-model="user.firstName" placeholder="Firstname">{{user.firstname}}</input>
30+
</div>
31+
32+
<div class="form-group">
33+
<input type="text" class="form-control" ng-model="user.lastName" placeholder="Lastname">{{user.Lastname}}</input>
34+
</div>
35+
36+
<div class="form-group">
37+
<input type="text" class="form-control" ng-model="user.adr1" placeholder="Address">{{user.adr1}}</input>
38+
</div>
39+
40+
<div class="form-group">
41+
<input type="text" class="form-control" ng-model="user.adr2" placeholder="Rest of the address ">{{user.adr2}}</input>
42+
</div>
43+
44+
<div class="form-group">
45+
<input type="text" class="form-control" ng-model="user.pc" placeholder="Postal Code ">{{user.pc}}</input>
46+
</div>
47+
48+
<div class="form-group">
49+
<input type="text" class="form-control" ng-model="user.town" placeholder="Town ">{{user.town}}</input>
50+
</div>
51+
52+
<div class="form-group">
53+
<input type="text" class="form-control" ng-model="user.phone" placeholder="Phone ">{{user.phone}}</input>
54+
</div>
55+
56+
<button type="button" id="cancel" value="Cancel" class="btn btn-danger" />
57+
<input type="submit" id="submit" value="Apply changes" class="btn btn-primary" />
58+
</form>
59+
<button type="button" id="submit" value="Become Member" class="btn btn-success btn-lg" />
60+
</div>
61+
</div>
62+
</div>
63+

Diff for: Zenergy/Zenergy/Zenergy.csproj

+10
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@
302302
<Content Include="favicon.ico" />
303303
<Content Include="fonts\glyphicons-halflings-regular.svg" />
304304
<Content Include="Global.asax" />
305+
<<<<<<< HEAD
305306
<Content Include="Pages\profile.html" />
307+
=======
308+
<Content Include="Scripts\Controllers\accountManagementPageController.js" />
309+
>>>>>>> adding view/controller and BE controller
306310
<Content Include="Scripts\Controllers\homePageController.js" />
307311
<Content Include="Scripts\Controllers\loginPageController.js" />
308312
<Content Include="Scripts\Controllers\mainController.js" />
@@ -1157,9 +1161,15 @@
11571161
<Content Include="Models\ZenergyModel.edmx.diagram">
11581162
<DependentUpon>ZenergyModel.edmx</DependentUpon>
11591163
</Content>
1164+
<<<<<<< HEAD
11601165
<Content Include="Pages\login.html" />
11611166
<Content Include="Views\Shared\_Layout.cshtml" />
11621167
<Content Include="Pages\register.html" />
1168+
=======
1169+
<Content Include="Views\Login\index.cshtml" />
1170+
<Content Include="Views\Register\index.cshtml" />
1171+
<Content Include="Views\AccountManagement\index.cshtml" />
1172+
>>>>>>> adding view/controller and BE controller
11631173
</ItemGroup>
11641174
<ItemGroup>
11651175
<Folder Include="App_Data\" />

0 commit comments

Comments
 (0)