Skip to content

Commit 6c03804

Browse files
committed
Merge branch 'eventManagement' of https://github.com/damienmoulard/Zenergy into eventRegistration-feature
Conflicts: Zenergy/Zenergy/Zenergy.csproj
2 parents 72b413b + 8ddff93 commit 6c03804

File tree

4 files changed

+283
-0
lines changed

4 files changed

+283
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+
using Zenergy.Services;
14+
15+
namespace Zenergy.Controllers.ApiControllers
16+
{
17+
public class ponctualEventsController : ApiController
18+
{
19+
private ZenergyContext db = new ZenergyContext();
20+
21+
// GET: api/ponctualEvents
22+
public IQueryable<ponctualEvent> GetponctualEvent()
23+
{
24+
return db.ponctualEvent;
25+
}
26+
27+
// GET: api/ponctualEvents/5
28+
[ResponseType(typeof(ponctualEvent))]
29+
public async Task<IHttpActionResult> GetponctualEvent(int id)
30+
{
31+
ponctualEvent ponctualEvent = await db.ponctualEvent.FindAsync(id);
32+
if (ponctualEvent == null)
33+
{
34+
return NotFound();
35+
}
36+
37+
return Ok(ponctualEvent);
38+
}
39+
40+
// PUT: api/ponctualEvents/5
41+
[ResponseType(typeof(void))]
42+
public async Task<IHttpActionResult> PutponctualEvent(int id, ponctualEvent ponctualEvent)
43+
{
44+
if (!ModelState.IsValid)
45+
{
46+
return BadRequest(ModelState);
47+
}
48+
49+
if (id != ponctualEvent.eventId)
50+
{
51+
return BadRequest();
52+
}
53+
54+
db.Entry(ponctualEvent).State = EntityState.Modified;
55+
56+
try
57+
{
58+
await db.SaveChangesAsync();
59+
}
60+
catch (DbUpdateConcurrencyException)
61+
{
62+
if (!ponctualEventExists(id))
63+
{
64+
return NotFound();
65+
}
66+
else
67+
{
68+
throw;
69+
}
70+
}
71+
72+
return StatusCode(HttpStatusCode.NoContent);
73+
}
74+
75+
// POST: api/ponctualEvents
76+
[ResponseType(typeof(ponctualEvent))]
77+
public async Task<IHttpActionResult> PostponctualEvent(ponctualEvent ponctualEvent)
78+
{
79+
if (!ModelState.IsValid)
80+
{
81+
return BadRequest(ModelState);
82+
}
83+
84+
db.ponctualEvent.Add(ponctualEvent);
85+
86+
try
87+
{
88+
await db.SaveChangesAsync();
89+
}
90+
catch (DbUpdateException)
91+
{
92+
if (ponctualEventExists(ponctualEvent.eventId))
93+
{
94+
return Conflict();
95+
}
96+
else
97+
{
98+
throw;
99+
}
100+
}
101+
102+
return CreatedAtRoute("DefaultApi", new { id = ponctualEvent.eventId }, ponctualEvent);
103+
}
104+
105+
// DELETE: api/ponctualEvents/5
106+
[ResponseType(typeof(ponctualEvent))]
107+
public async Task<IHttpActionResult> DeleteponctualEvent(int id)
108+
{
109+
ponctualEvent ponctualEvent = await db.ponctualEvent.FindAsync(id);
110+
if (ponctualEvent == null)
111+
{
112+
return NotFound();
113+
}
114+
115+
db.ponctualEvent.Remove(ponctualEvent);
116+
await db.SaveChangesAsync();
117+
118+
return Ok(ponctualEvent);
119+
}
120+
121+
protected override void Dispose(bool disposing)
122+
{
123+
if (disposing)
124+
{
125+
db.Dispose();
126+
}
127+
base.Dispose(disposing);
128+
}
129+
130+
private bool ponctualEventExists(int id)
131+
{
132+
return db.ponctualEvent.Count(e => e.eventId == id) > 0;
133+
}
134+
}
135+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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 regularEventsController : ApiController
17+
{
18+
private ZenergyContext db = new ZenergyContext();
19+
20+
// GET: api/regularEvents
21+
public IQueryable<regularEvent> GetregularEvent()
22+
{
23+
return db.regularEvent;
24+
}
25+
26+
// GET: api/regularEvents/5
27+
[ResponseType(typeof(regularEvent))]
28+
public async Task<IHttpActionResult> GetregularEvent(int id)
29+
{
30+
regularEvent regularEvent = await db.regularEvent.FindAsync(id);
31+
if (regularEvent == null)
32+
{
33+
return NotFound();
34+
}
35+
36+
return Ok(regularEvent);
37+
}
38+
39+
// PUT: api/regularEvents/5
40+
[ResponseType(typeof(void))]
41+
public async Task<IHttpActionResult> PutregularEvent(int id, regularEvent regularEvent)
42+
{
43+
if (!ModelState.IsValid)
44+
{
45+
return BadRequest(ModelState);
46+
}
47+
48+
if (id != regularEvent.eventId)
49+
{
50+
return BadRequest();
51+
}
52+
53+
db.Entry(regularEvent).State = EntityState.Modified;
54+
55+
try
56+
{
57+
await db.SaveChangesAsync();
58+
}
59+
catch (DbUpdateConcurrencyException)
60+
{
61+
if (!regularEventExists(id))
62+
{
63+
return NotFound();
64+
}
65+
else
66+
{
67+
throw;
68+
}
69+
}
70+
71+
return StatusCode(HttpStatusCode.NoContent);
72+
}
73+
74+
// POST: api/regularEvents
75+
[ResponseType(typeof(regularEvent))]
76+
public async Task<IHttpActionResult> PostregularEvent(regularEvent regularEvent)
77+
{
78+
if (!ModelState.IsValid)
79+
{
80+
return BadRequest(ModelState);
81+
}
82+
83+
db.regularEvent.Add(regularEvent);
84+
85+
try
86+
{
87+
await db.SaveChangesAsync();
88+
}
89+
catch (DbUpdateException)
90+
{
91+
if (regularEventExists(regularEvent.eventId))
92+
{
93+
return Conflict();
94+
}
95+
else
96+
{
97+
throw;
98+
}
99+
}
100+
101+
return CreatedAtRoute("DefaultApi", new { id = regularEvent.eventId }, regularEvent);
102+
}
103+
104+
// DELETE: api/regularEvents/5
105+
[ResponseType(typeof(regularEvent))]
106+
public async Task<IHttpActionResult> DeleteregularEvent(int id)
107+
{
108+
regularEvent regularEvent = await db.regularEvent.FindAsync(id);
109+
if (regularEvent == null)
110+
{
111+
return NotFound();
112+
}
113+
114+
db.regularEvent.Remove(regularEvent);
115+
await db.SaveChangesAsync();
116+
117+
return Ok(regularEvent);
118+
}
119+
120+
protected override void Dispose(bool disposing)
121+
{
122+
if (disposing)
123+
{
124+
db.Dispose();
125+
}
126+
base.Dispose(disposing);
127+
}
128+
129+
private bool regularEventExists(int id)
130+
{
131+
return db.regularEvent.Count(e => e.eventId == id) > 0;
132+
}
133+
}
134+
}

Diff for: Zenergy/Zenergy/Services/EventService.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
6+
namespace Zenergy.Services
7+
{
8+
public class EventService
9+
{
10+
}
11+
}

Diff for: Zenergy/Zenergy/Zenergy.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@
179179
<Compile Include="Controllers\ApiControllers\roomContentsController.cs" />
180180
<Compile Include="Controllers\ApiControllers\roomsController.cs" />
181181
<Compile Include="Controllers\ApiControllers\accessoriesController.cs" />
182+
<Compile Include="Controllers\ApiControllers\ponctualEventsController.cs" />
183+
<Compile Include="Controllers\ApiControllers\regularEventsController.cs" />
182184
<Compile Include="Controllers\ApiControllers\usersController.cs" />
183185
<Compile Include="Controllers\HomeController.cs" />
184186
<Compile Include="Models\accessory.cs">
@@ -276,6 +278,7 @@
276278
<Compile Include="Models\roomContent.cs">
277279
<DependentUpon>ZenergyModel.tt</DependentUpon>
278280
</Compile>
281+
<Compile Include="Services\EventService.cs" />
279282
<Compile Include="Services\UserServices.cs" />
280283
<Compile Include="Startup.cs" />
281284
<Compile Include="Models\user.cs">

0 commit comments

Comments
 (0)