// GET: api/Activities?userId=xyz public IEnumerable <ActivityDto> GetActivities(String userId) { if (userId == "current") { userId = User.Identity.GetUserId(); } return(actSvc.GetActivities(userId).Select(a => ActivityDto.FromActivity(a))); }
public IHttpActionResult GetActivity(long id) { var a = actSvc.GetActivity(id); if (a == null) { return(NotFound()); } return(Ok(ActivityDto.FromActivity(a))); }
public IHttpActionResult PostActivity(Activity activity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } String uid = User.Identity.GetUserId(); if (uid == null) { uid = activity.UserID; } actSvc.CreateActivity(activity, uid); uow.Save(); return(CreatedAtRoute("DefaultApi", new { id = activity.ID }, ActivityDto.FromActivity(activity))); }
//GET: api/Activities public IEnumerable <ActivityDto> GetActivities() { return(actSvc.GetActivities().Select(a => ActivityDto.FromActivity(a))); }