Skip to content

Commit 220b8be

Browse files
committed
Rebase from master
2 parents 3b19fbd + 1df8a09 commit 220b8be

19 files changed

+648
-28
lines changed

Diff for: Zenergy/Zenergy/App_Start/BundleConfig.cs

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public static void RegisterBundles(BundleCollection bundles)
2525
bundles.Add(new ScriptBundle("~/bundles/angular-route").Include(
2626
"~/Scripts/Lib/angular-route.min.js"));
2727

28+
bundles.Add(new ScriptBundle("~/bundles/ui-bootstrap").Include(
29+
"~/Scripts/Lib/ui-bootstrap-tpls-0.14.3.min.js"));
30+
2831
bundles.Add(new ScriptBundle("~/bundles/zenergyApp")
2932
.Include("~/Scripts/zenergyApp.js")
3033
.IncludeDirectory("~/Scripts/Controllers", "*.js")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Data.Entity;
5+
using System.Data.Entity.Infrastructure;
6+
using System.Linq;
7+
using System.Net;
8+
using System.Net.Http;
9+
using System.Threading.Tasks;
10+
using System.Web.Http;
11+
using System.Web.Http.Description;
12+
using Zenergy.Models;
13+
14+
namespace Zenergy.Controllers.ApiControllers
15+
{
16+
public class adminsController : ApiController
17+
{
18+
private ZenergyContext db = new ZenergyContext();
19+
20+
// GET: api/admins/5
21+
[ResponseType(typeof(admin))]
22+
public async Task<IHttpActionResult> Getadmin(int id)
23+
{
24+
admin admin = await db.admin.FindAsync(id);
25+
if (admin == null)
26+
{
27+
return NotFound();
28+
}
29+
30+
return Ok(admin);
31+
}
32+
33+
// POST: api/admins
34+
[ResponseType(typeof(admin))]
35+
public async Task<IHttpActionResult> Postadmin(admin admin)
36+
{
37+
if (!ModelState.IsValid)
38+
{
39+
return BadRequest(ModelState);
40+
}
41+
42+
db.admin.Add(admin);
43+
44+
try
45+
{
46+
await db.SaveChangesAsync();
47+
}
48+
catch (DbUpdateException)
49+
{
50+
if (adminExists(admin.userId))
51+
{
52+
return Conflict();
53+
}
54+
else
55+
{
56+
throw;
57+
}
58+
}
59+
60+
return CreatedAtRoute("DefaultApi", new { id = admin.userId }, admin);
61+
}
62+
63+
// DELETE: api/admins/5
64+
[ResponseType(typeof(admin))]
65+
public async Task<IHttpActionResult> Deleteadmin(int id)
66+
{
67+
admin admin = await db.admin.FindAsync(id);
68+
if (admin == null)
69+
{
70+
return NotFound();
71+
}
72+
73+
db.admin.Remove(admin);
74+
await db.SaveChangesAsync();
75+
76+
return Ok(admin);
77+
}
78+
79+
protected override void Dispose(bool disposing)
80+
{
81+
if (disposing)
82+
{
83+
db.Dispose();
84+
}
85+
base.Dispose(disposing);
86+
}
87+
88+
private bool adminExists(int id)
89+
{
90+
return db.admin.Count(e => e.userId == id) > 0;
91+
}
92+
}
93+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Data.Entity;
5+
using System.Data.Entity.Infrastructure;
6+
using System.Linq;
7+
using System.Net;
8+
using System.Net.Http;
9+
using System.Threading.Tasks;
10+
using System.Web.Http;
11+
using System.Web.Http.Description;
12+
using Zenergy.Models;
13+
14+
namespace Zenergy.Controllers.ApiControllers
15+
{
16+
public class contributorsController : ApiController
17+
{
18+
private ZenergyContext db = new ZenergyContext();
19+
20+
// GET: api/contributors/5
21+
[ResponseType(typeof(contributor))]
22+
public async Task<IHttpActionResult> Getcontributor(int id)
23+
{
24+
contributor contributor = await db.contributor.FindAsync(id);
25+
if (contributor == null)
26+
{
27+
return NotFound();
28+
}
29+
30+
return Ok(contributor);
31+
}
32+
33+
// POST: api/contributors
34+
[ResponseType(typeof(contributor))]
35+
public async Task<IHttpActionResult> Postcontributor(contributor contributor)
36+
{
37+
if (!ModelState.IsValid)
38+
{
39+
return BadRequest(ModelState);
40+
}
41+
42+
db.contributor.Add(contributor);
43+
44+
try
45+
{
46+
await db.SaveChangesAsync();
47+
}
48+
catch (DbUpdateException)
49+
{
50+
if (contributorExists(contributor.userId))
51+
{
52+
return Conflict();
53+
}
54+
else
55+
{
56+
throw;
57+
}
58+
}
59+
60+
return CreatedAtRoute("DefaultApi", new { id = contributor.userId }, contributor);
61+
}
62+
63+
// DELETE: api/contributors/5
64+
[ResponseType(typeof(contributor))]
65+
public async Task<IHttpActionResult> Deletecontributor(int id)
66+
{
67+
contributor contributor = await db.contributor.FindAsync(id);
68+
if (contributor == null)
69+
{
70+
return NotFound();
71+
}
72+
73+
db.contributor.Remove(contributor);
74+
await db.SaveChangesAsync();
75+
76+
return Ok(contributor);
77+
}
78+
79+
protected override void Dispose(bool disposing)
80+
{
81+
if (disposing)
82+
{
83+
db.Dispose();
84+
}
85+
base.Dispose(disposing);
86+
}
87+
88+
private bool contributorExists(int id)
89+
{
90+
return db.contributor.Count(e => e.userId == id) > 0;
91+
}
92+
}
93+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Data.Entity;
5+
using System.Data.Entity.Infrastructure;
6+
using System.Linq;
7+
using System.Net;
8+
using System.Net.Http;
9+
using System.Threading.Tasks;
10+
using System.Web.Http;
11+
using System.Web.Http.Description;
12+
using Zenergy.Models;
13+
14+
namespace Zenergy.Controllers.ApiControllers
15+
{
16+
public class managersController : ApiController
17+
{
18+
private ZenergyContext db = new ZenergyContext();
19+
20+
// GET: api/managers/5
21+
[ResponseType(typeof(manager))]
22+
public async Task<IHttpActionResult> Getmanager(int id)
23+
{
24+
manager manager = await db.manager.FindAsync(id);
25+
if (manager == null)
26+
{
27+
return NotFound();
28+
}
29+
30+
return Ok(manager);
31+
}
32+
33+
// POST: api/managers
34+
[ResponseType(typeof(manager))]
35+
public async Task<IHttpActionResult> Postmanager(manager manager)
36+
{
37+
if (!ModelState.IsValid)
38+
{
39+
return BadRequest(ModelState);
40+
}
41+
42+
db.manager.Add(manager);
43+
44+
try
45+
{
46+
await db.SaveChangesAsync();
47+
}
48+
catch (DbUpdateException)
49+
{
50+
if (managerExists(manager.userId))
51+
{
52+
return Conflict();
53+
}
54+
else
55+
{
56+
throw;
57+
}
58+
}
59+
60+
return CreatedAtRoute("DefaultApi", new { id = manager.userId }, manager);
61+
}
62+
63+
// DELETE: api/managers/5
64+
[ResponseType(typeof(manager))]
65+
public async Task<IHttpActionResult> Deletemanager(int id)
66+
{
67+
manager manager = await db.manager.FindAsync(id);
68+
if (manager == null)
69+
{
70+
return NotFound();
71+
}
72+
73+
db.manager.Remove(manager);
74+
await db.SaveChangesAsync();
75+
76+
return Ok(manager);
77+
}
78+
79+
protected override void Dispose(bool disposing)
80+
{
81+
if (disposing)
82+
{
83+
db.Dispose();
84+
}
85+
base.Dispose(disposing);
86+
}
87+
88+
private bool managerExists(int id)
89+
{
90+
return db.manager.Count(e => e.userId == id) > 0;
91+
}
92+
}
93+
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
7+
namespace Zenergy.Controllers
8+
{
9+
public class UsersController : Controller
10+
{
11+
public ActionResult Index()
12+
{
13+
return View();
14+
}
15+
}
16+
}

Diff for: Zenergy/Zenergy/Pages/users.html

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<div class="container ">
2+
<div class="row">
3+
<div class="col-md-12">
4+
<h2>Users managment</h2>
5+
<form>
6+
<div class="form-group">
7+
<div class="input-group">
8+
<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
9+
10+
<input type="text" class="form-control" placeholder="Search for an User" ng-model="searchUser">
11+
12+
</div>
13+
</div>
14+
</form>
15+
<script type="text/ng-template" id="myModalContent.html">
16+
<div class="modal-header">
17+
<h3 class="modal-title">Are you sur you want to delete {{userTodelete.firstname}} ?</h3>
18+
</div>
19+
<div class="modal-footer">
20+
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
21+
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
22+
</div>
23+
</script>
24+
25+
26+
<table class="table table-striped">
27+
<thead>
28+
<tr>
29+
<th>
30+
<a href="" ng-click="sortType = 'userId' ; sortReverse = !sortReverse">
31+
User ID
32+
<span ng-show="sortType == 'userId' && sortReverse" class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
33+
<span ng-show="sortType == 'userId' && !sortReverse" class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span>
34+
</a>
35+
</th>
36+
<th>
37+
<a href="" ng-click="sortType = 'firstname'; sortReverse = !sortReverse">
38+
Firstname
39+
<span ng-show="sortType == 'firstname' && sortReverse" class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
40+
<span ng-show="sortType == 'firstname' && !sortReverse" class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span>
41+
</a>
42+
</th>
43+
<th>
44+
<a href="" ng-click="sortType = 'lastname'; sortReverse = !sortReverse">
45+
Lastname
46+
<span ng-show="sortType == 'lastname' && sortReverse" class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
47+
<span ng-show="sortType == 'lastname' && !sortReverse" class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span>
48+
</a>
49+
</th>
50+
<th>
51+
<a href="" ng-click="sortType = 'mail'; sortReverse = !sortReverse">
52+
Email
53+
<span ng-show="sortType == 'mail' && sortReverse" class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
54+
<span ng-show="sortType == 'mail' && !sortReverse" class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span>
55+
</a>
56+
</th>
57+
<th><a href="">Admin</a></th>
58+
<th><a href="">Manager</a></th>
59+
<th><a href="">Contributor</a></th>
60+
<th><a href="">Member</a></th>
61+
</tr>
62+
</thead>
63+
<tbody>
64+
<tr ng-repeat="u in users | orderBy:sortType:sortReverse| filter:searchUser" id="tr{{u.userId}}" ng-init="u.adminChecked=(u.admin!=undefined); u.managerChecked=(u.manager!=undefined); u.contributorChecked=(u.contributor!=undefined); u.memberChecked=(u.member!=undefined)">
65+
<td>{{u.userId}}</td>
66+
<td>{{u.firstname}}</td>
67+
<td>{{u.lastname}}</td>
68+
<td>{{u.mail}}</td>
69+
<td><label><input type="checkbox" ng-checked="u.admin" ng-model="u.adminChecked"/></label></td>
70+
<td><label><input type="checkbox" ng-checked="u.manager" ng-model="u.managerChecked"/></label></td>
71+
<td><label><input type="checkbox" ng-checked="u.contributor" ng-model="u.contributorChecked"/></label></td>
72+
<td><label><input type="checkbox" ng-checked="u.member" ng-model="u.memberChecked"/></label></td>
73+
<td><input class="btn btn-danger btn-sm" value="delete" ng-click="open(u)"/></td>
74+
</tr>
75+
</tbody>
76+
</table>
77+
</div>
78+
<div class="col-md-1 col-md-offset-10">
79+
<button class="btn btn-primary btn-lg" ng-click="validate()">Validate</button>
80+
</div>
81+
</div>
82+
</div>
83+
</div>

0 commit comments

Comments
 (0)