Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit 1df8034

Browse files
committed
Application clean up
- Removed unused controller actions and controllers - Removed tags, conferences (the schema only supports a single conference) - Fixed ID casing
1 parent 306885b commit 1df8034

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+330
-1037
lines changed

src/BackEnd/BackEnd.csproj

+10
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55
<UserSecretsId>aspnet-BackEnd-931E56BD-86CB-4A96-BD99-2C6A6ABB0829</UserSecretsId>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Migrations\20190126203326_Initial.cs" />
10+
<Compile Remove="Migrations\20190126203326_Initial.Designer.cs" />
11+
<Compile Remove="Migrations\20190516071446_Initial.cs" />
12+
<Compile Remove="Migrations\20190516071446_Initial.Designer.cs" />
13+
<Compile Remove="Migrations\20190516072754_Initial.cs" />
14+
<Compile Remove="Migrations\20190516072754_Initial.Designer.cs" />
15+
</ItemGroup>
16+
817
<ItemGroup>
918
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview5*" />
1019
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview5*" />
1120
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0-preview5*" />
21+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview5*" />
1222
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.0.0-preview5*" />
1323
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview5*" />
1424
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />

src/BackEnd/Controllers/AttendeesController.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public async Task<ActionResult<AttendeeResponse>> Post(ConferenceDTO.Attendee in
6868
return CreatedAtAction(nameof(Get), new { id = result.UserName }, result);
6969
}
7070

71-
[HttpPost("{username}/session/{sessionId:int}")]
71+
[HttpPost("{username}/session/{sessionId}")]
7272
[ProducesResponseType(StatusCodes.Status200OK)]
7373
[ProducesResponseType(StatusCodes.Status400BadRequest)]
7474
[ProducesResponseType(StatusCodes.Status404NotFound)]
@@ -77,8 +77,6 @@ public async Task<ActionResult<AttendeeResponse>> AddSession(string username, in
7777
{
7878
var attendee = await _db.Attendees.Include(a => a.SessionsAttendees)
7979
.ThenInclude(sa => sa.Session)
80-
.Include(a => a.ConferenceAttendees)
81-
.ThenInclude(ca => ca.Conference)
8280
.SingleOrDefaultAsync(a => a.UserName == username);
8381

8482
if (attendee == null)
@@ -95,8 +93,8 @@ public async Task<ActionResult<AttendeeResponse>> AddSession(string username, in
9593

9694
attendee.SessionsAttendees.Add(new SessionAttendee
9795
{
98-
AttendeeID = attendee.ID,
99-
SessionID = sessionId
96+
AttendeeId = attendee.Id,
97+
SessionId = sessionId
10098
});
10199

102100
await _db.SaveChangesAsync();
@@ -106,7 +104,7 @@ public async Task<ActionResult<AttendeeResponse>> AddSession(string username, in
106104
return result;
107105
}
108106

109-
[HttpDelete("{username}/session/{sessionId:int}")]
107+
[HttpDelete("{username}/session/{sessionId}")]
110108
[ProducesResponseType(StatusCodes.Status204NoContent)]
111109
[ProducesResponseType(StatusCodes.Status400BadRequest)]
112110
[ProducesResponseType(StatusCodes.Status404NotFound)]
@@ -128,7 +126,7 @@ public async Task<IActionResult> RemoveSession(string username, int sessionId)
128126
return BadRequest();
129127
}
130128

131-
var sessionAttendee = attendee.SessionsAttendees.FirstOrDefault(sa => sa.SessionID == sessionId);
129+
var sessionAttendee = attendee.SessionsAttendees.FirstOrDefault(sa => sa.SessionId == sessionId);
132130
attendee.SessionsAttendees.Remove(sessionAttendee);
133131

134132
await _db.SaveChangesAsync();

src/BackEnd/Controllers/ConferencesController.cs

-146
This file was deleted.

src/BackEnd/Controllers/SearchController.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,21 @@ public async Task<ActionResult<List<SearchResult>>> Search(SearchTerm term)
4747
Type = SearchResultType.Session,
4848
Value = JObject.FromObject(new SessionResponse
4949
{
50-
ID = s.ID,
50+
Id = s.Id,
5151
Title = s.Title,
5252
Abstract = s.Abstract,
53-
ConferenceID = s.ConferenceID,
5453
StartTime = s.StartTime,
5554
EndTime = s.EndTime,
5655
TrackId = s.TrackId,
5756
Track = new ConferenceDTO.Track
5857
{
59-
TrackID = s?.TrackId ?? 0,
58+
Id = s?.TrackId ?? 0,
6059
Name = s.Track?.Name
6160
},
6261
Speakers = s?.SessionSpeakers
6362
.Select(ss => new ConferenceDTO.Speaker
6463
{
65-
ID = ss.SpeakerId,
64+
Id = ss.SpeakerId,
6665
Name = ss.Speaker.Name
6766
})
6867
.ToList()
@@ -73,15 +72,15 @@ public async Task<ActionResult<List<SearchResult>>> Search(SearchTerm term)
7372
Type = SearchResultType.Speaker,
7473
Value = JObject.FromObject(new SpeakerResponse
7574
{
76-
ID = s.ID,
75+
Id = s.Id,
7776
Name = s.Name,
7877
Bio = s.Bio,
7978
WebSite = s.WebSite,
8079
Sessions = s.SessionSpeakers?
8180
.Select(ss =>
8281
new ConferenceDTO.Session
8382
{
84-
ID = ss.SessionId,
83+
Id = ss.SessionId,
8584
Title = ss.Session.Title
8685
})
8786
.ToList()

src/BackEnd/Controllers/SessionsController.cs

+42-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System.Collections.Generic;
2+
using System.ComponentModel.DataAnnotations;
23
using System.Linq;
34
using System.Threading.Tasks;
4-
using Microsoft.AspNetCore.Mvc;
5-
using Microsoft.EntityFrameworkCore;
65
using BackEnd.Data;
76
using ConferenceDTO;
7+
using Microsoft.AspNetCore.Http;
8+
using Microsoft.AspNetCore.Mvc;
9+
using Microsoft.EntityFrameworkCore;
810

911
namespace BackEnd.Controllers
1012
{
@@ -26,23 +28,19 @@ public async Task<ActionResult<List<SessionResponse>>> Get()
2628
.Include(s => s.Track)
2729
.Include(s => s.SessionSpeakers)
2830
.ThenInclude(ss => ss.Speaker)
29-
.Include(s => s.SessionTags)
30-
.ThenInclude(st => st.Tag)
3131
.Select(m => m.MapSessionResponse())
3232
.ToListAsync();
3333
return sessions;
3434
}
3535

36-
[HttpGet("{id:int}")]
36+
[HttpGet("{id}")]
3737
public async Task<ActionResult<SessionResponse>> Get(int id)
3838
{
3939
var session = await _db.Sessions.AsNoTracking()
4040
.Include(s => s.Track)
4141
.Include(s => s.SessionSpeakers)
4242
.ThenInclude(ss => ss.Speaker)
43-
.Include(s => s.SessionTags)
44-
.ThenInclude(st => st.Tag)
45-
.SingleOrDefaultAsync(s => s.ID == id);
43+
.SingleOrDefaultAsync(s => s.Id == id);
4644

4745
if (session == null)
4846
{
@@ -58,7 +56,6 @@ public async Task<ActionResult<SessionResponse>> Post(ConferenceDTO.Session inpu
5856
var session = new Data.Session
5957
{
6058
Title = input.Title,
61-
ConferenceID = input.ConferenceID,
6259
StartTime = input.StartTime,
6360
EndTime = input.EndTime,
6461
Abstract = input.Abstract,
@@ -70,10 +67,10 @@ public async Task<ActionResult<SessionResponse>> Post(ConferenceDTO.Session inpu
7067

7168
var result = session.MapSessionResponse();
7269

73-
return CreatedAtAction(nameof(Get), new { id = result.ID }, result);
70+
return CreatedAtAction(nameof(Get), new { id = result.Id }, result);
7471
}
7572

76-
[HttpPut("{id:int}")]
73+
[HttpPut("{id}")]
7774
public async Task<IActionResult> Put(int id, ConferenceDTO.Session input)
7875
{
7976
var session = await _db.Sessions.FindAsync(id);
@@ -83,20 +80,19 @@ public async Task<IActionResult> Put(int id, ConferenceDTO.Session input)
8380
return NotFound();
8481
}
8582

86-
session.ID = input.ID;
83+
session.Id = input.Id;
8784
session.Title = input.Title;
8885
session.Abstract = input.Abstract;
8986
session.StartTime = input.StartTime;
9087
session.EndTime = input.EndTime;
9188
session.TrackId = input.TrackId;
92-
session.ConferenceID = input.ConferenceID;
9389

9490
await _db.SaveChangesAsync();
9591

9692
return NoContent();
9793
}
9894

99-
[HttpDelete("{id:int}")]
95+
[HttpDelete("{id}")]
10096
public async Task<ActionResult<SessionResponse>> Delete(int id)
10197
{
10298
var session = await _db.Sessions.FindAsync(id);
@@ -111,5 +107,37 @@ public async Task<ActionResult<SessionResponse>> Delete(int id)
111107

112108
return session.MapSessionResponse();
113109
}
110+
111+
112+
[HttpPost("upload")]
113+
[Consumes("multipart/form-data")]
114+
public async Task<IActionResult> Upload([FromForm]ConferenceFormat format, IFormFile file)
115+
{
116+
var loader = GetLoader(format);
117+
118+
using (var stream = file.OpenReadStream())
119+
{
120+
await loader.LoadDataAsync(stream, _db);
121+
}
122+
123+
await _db.SaveChangesAsync();
124+
125+
return Ok();
126+
}
127+
128+
private static DataLoader GetLoader(ConferenceFormat format)
129+
{
130+
if (format == ConferenceFormat.Sessionize)
131+
{
132+
return new SessionizeLoader();
133+
}
134+
return new DevIntersectionLoader();
135+
}
136+
137+
public enum ConferenceFormat
138+
{
139+
Sessionize,
140+
DevIntersections
141+
}
114142
}
115143
}

0 commit comments

Comments
 (0)