public IHttpActionResult Get() { IList <FileDTO> fileList; if (_security.IsCurrentUserHasRole(Roles.Admin)) { fileList = Mapper.Map <IList <FileDTO> >(_fileService.AllFilesList()); } else { string userId; using (var uow = ObjectFactory.GetInstance <IUnitOfWork>()) { userId = _security.GetCurrentAccount(uow).Id; } fileList = Mapper.Map <IList <FileDTO> >(_fileService.FilesList(userId)); } // fills Tags property for each fileDTO to display in the Tags column // example: { "key1" : "value1" }, {"key2", "value2} ... foreach (var file in fileList) { var result = String.Empty; var tags = _tagService.GetList(file.Id); bool isFirstItem = true; foreach (var tag in tags) { if (isFirstItem) { isFirstItem = false; } else { result += ", "; } result += "{\"" + tag.Key + "\" : \"" + tag.Value + "\"}"; } file.Tags = result; } return(Ok(fileList)); }