public IHttpActionResult Get(int id) { try { Timeline timeline = _service.Get(id); return(Ok(timeline)); } catch (TimelineNotFoundException) { return(NotFound()); } catch (Exception) { return(BadRequest("An error occured")); } }
public IHttpActionResult Delete(int timelinePostId) { //first get the timeline post var post = _timelineService.Get(timelinePostId); if (post == null) { return(Response(new { Success = false, Message = "Post doesn't exist" })); } //only admin or post owner should be able to delete the post if (post.OwnerId == ApplicationContext.Current.CurrentUser.Id || ApplicationContext.Current.CurrentUser.IsAdministrator()) { _timelineService.Delete(post); return(Response(new { Success = true })); } return(Response(new { Success = false, Message = "Unauthorized" })); }