Skip to content

Commit 07b7384

Browse files
committed
SortUserEventByActivity OK
1 parent 3621484 commit 07b7384

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: Zenergy/Zenergy/Controllers/ApiControllers/eventsController.cs

+18
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ public async Task<IHttpActionResult> GetMyEvent(int userId)
7474
return Ok(myUser.@event);
7575
}
7676

77+
[HttpGet]
78+
[ResponseType(typeof(@event))]
79+
[Route("SortUserEventByActivity")]
80+
public async Task<IHttpActionResult> SortUserEventByActivity(int userId)
81+
{
82+
var user = await db.user.FindAsync(userId);
83+
if(user == null)
84+
{
85+
return BadRequest("This user does not exist.");
86+
}
87+
if (!user.@event.Any())
88+
{
89+
return BadRequest("User has not registered to event yet.");
90+
}
91+
return Ok(user.@event.OrderBy(e => e.activity.activityName));
92+
}
93+
94+
7795

7896

7997
/// <summary>

0 commit comments

Comments
 (0)