Skip to content

Commit 25becfd

Browse files
committed
Rebase from master
2 parents 64b5f08 + 7b0fc49 commit 25becfd

25 files changed

+1351
-34
lines changed

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,118 @@
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.Web.Http;
10+
using System.Web.Http.Description;
11+
using Zenergy.Models;
12+
13+
namespace Zenergy.Controllers.ApiControllers
14+
{
15+
public class categoriesController : ApiController
16+
{
17+
private ZenergyContext db = new ZenergyContext();
18+
19+
// GET: api/categories
20+
public IQueryable<category> Getcategory()
21+
{
22+
return db.category;
23+
}
24+
25+
// GET: api/categories/5
26+
[ResponseType(typeof(category))]
27+
public IHttpActionResult Getcategory(int id)
28+
{
29+
category category = db.category.Find(id);
30+
if (category == null)
31+
{
32+
return NotFound();
33+
}
34+
35+
return Ok(category);
36+
}
37+
38+
// PUT: api/categories/5
39+
[ResponseType(typeof(void))]
40+
public IHttpActionResult Putcategory(int id, category category)
41+
{
42+
if (!ModelState.IsValid)
43+
{
44+
return BadRequest(ModelState);
45+
}
46+
47+
if (id != category.categoryId)
48+
{
49+
return BadRequest();
50+
}
51+
52+
db.Entry(category).State = EntityState.Modified;
53+
54+
try
55+
{
56+
db.SaveChanges();
57+
}
58+
catch (DbUpdateConcurrencyException)
59+
{
60+
if (!categoryExists(id))
61+
{
62+
return NotFound();
63+
}
64+
else
65+
{
66+
throw;
67+
}
68+
}
69+
70+
return StatusCode(HttpStatusCode.NoContent);
71+
}
72+
73+
// POST: api/categories
74+
[ResponseType(typeof(category))]
75+
public IHttpActionResult Postcategory(category category)
76+
{
77+
if (!ModelState.IsValid)
78+
{
79+
return BadRequest(ModelState);
80+
}
81+
82+
db.category.Add(category);
83+
db.SaveChanges();
84+
85+
return CreatedAtRoute("DefaultApi", new { id = category.categoryId }, category);
86+
}
87+
88+
// DELETE: api/categories/5
89+
[ResponseType(typeof(category))]
90+
public IHttpActionResult Deletecategory(int id)
91+
{
92+
category category = db.category.Find(id);
93+
if (category == null)
94+
{
95+
return NotFound();
96+
}
97+
98+
db.category.Remove(category);
99+
db.SaveChanges();
100+
101+
return Ok(category);
102+
}
103+
104+
protected override void Dispose(bool disposing)
105+
{
106+
if (disposing)
107+
{
108+
db.Dispose();
109+
}
110+
base.Dispose(disposing);
111+
}
112+
113+
private bool categoryExists(int id)
114+
{
115+
return db.category.Count(e => e.categoryId == id) > 0;
116+
}
117+
}
118+
}
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+
}

0 commit comments

Comments
 (0)