// get all files for given user public HttpResponseMessage GetUserFiles(Guid userId, Guid playlistId) { HttpResponseMessage response; List <CFileInfo> filesInfo = new List <CFileInfo>(); try { List <CFile> files = _fileContext.GetByPlaylistId(playlistId).ToList(); foreach (CFile file in files) { // do not return to user files that are not fully loaded if (file.Hash != null) { CFileInfo fileInfo = file.ToCFileInfo(); filesInfo.Add(fileInfo); } } response = Request.CreateResponse(HttpStatusCode.OK, filesInfo); return(response); } catch (Exception e)// in case program crashes? { HttpContext.Current.Response.StatusCode = (Int32)HttpStatusCode.BadRequest; throw new ContextException(e.Message, e); } }