Пример #1
0
 // 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)));
 }
Пример #2
0
        public IHttpActionResult GetActivity(long id)
        {
            var a = actSvc.GetActivity(id);

            if (a == null)
            {
                return(NotFound());
            }
            return(Ok(ActivityDto.FromActivity(a)));
        }
Пример #3
0
        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)));
        }
Пример #4
0
 //GET: api/Activities
 public IEnumerable <ActivityDto> GetActivities()
 {
     return(actSvc.GetActivities().Select(a => ActivityDto.FromActivity(a)));
 }