diff --git a/server/AyaNova/Controllers/TagGroupController.cs b/server/AyaNova/Controllers/TagGroupController.cs index aaf35211..efabdf4b 100644 --- a/server/AyaNova/Controllers/TagGroupController.cs +++ b/server/AyaNova/Controllers/TagGroupController.cs @@ -84,7 +84,7 @@ namespace AyaNova.Api.Controllers /// - /// Get TagGroup pick list + /// Get TagGroup pick list, list of tag groups with name and ID /// /// Required roles: AnyRole /// @@ -126,6 +126,39 @@ namespace AyaNova.Api.Controllers + + /// + /// Get Tag pick list from group + /// Required roles: AnyRole + /// + /// + /// TagGroupId + /// name value list of all tags in group + [HttpGet("TagsInGroupPickList")] + public async Task TagsInGroupPickList([FromRoute] long id) + { + if (!serverState.IsOpen) + { + return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); + } + + if (!Authorized.IsAuthorizedToReadFullRecord(HttpContext.Items, AyaType.TagGroup))//Note: anyone can read a tag-group, but that might change in future so keeping this code in + { + return StatusCode(401, new ApiNotAuthorizedResponse()); + } + + if (!ModelState.IsValid) + { + return BadRequest(new ApiErrorResponse(ModelState)); + } + + //Instantiate the business object handler + TagGroupBiz biz = new TagGroupBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items)); + + var l = await biz.GetTagsInGroupPickListAsync(id); + return Ok(new ApiOkResponse(l)); + } + /// /// Post TagGroup /// diff --git a/server/AyaNova/biz/TagGroupBiz.cs b/server/AyaNova/biz/TagGroupBiz.cs index c9dc19a1..9cdee528 100644 --- a/server/AyaNova/biz/TagGroupBiz.cs +++ b/server/AyaNova/biz/TagGroupBiz.cs @@ -142,6 +142,22 @@ namespace AyaNova.Biz } + //get picklist (simple non-paged) + internal async Task> GetTagsInGroupPickListAsync(long tagGroupId) + { + TODO: change this to return a name value list of tags in group + List l = new List(); + l = await ct.Locale + .OrderBy(m => m.Name) + .Select(m => new NameIdItem() + { + Id = m.Id, + Name = m.Name + }).ToListAsync(); + + return l; + + } //////////////////////////////////////////////////////////////////////////////////////////////// //UPDATE diff --git a/test/raven-integration/Tags/TagGroupOps.cs b/test/raven-integration/Tags/TagGroupOps.cs index 0e861171..24284a7d 100644 --- a/test/raven-integration/Tags/TagGroupOps.cs +++ b/test/raven-integration/Tags/TagGroupOps.cs @@ -11,6 +11,14 @@ namespace raven_integration public class TagGroupOps { + //OPS + //CREATE A GROUP + //TAG A WIDGET WITH A GROUP OF TAGS + //GET A PICKLIST OF ALL TAGS IN A GROUP?? + //GET A ID ONLY LIST OF ALL TAG ID's IN A GROUP + //DELETE A GROUP + + /// /// Test taggroup ///