Exemple #1
0
        public async Task <IActionResult> AddItem([FromRoute] string projectKey, [FromBody] UpsertItemParams ps)
        {
            if (!await _permissionService.HasProjectPermissionAsync(projectKey, Permission.Admin))
            {
                return(StatusCode(403, "You have no permission to add item."));
            }

            ps.ProjectKey = projectKey;
            return(Ok(await _itemService.AddItemAsync(ps)));
        }
Exemple #2
0
        public async Task <IActionResult> UpdateItem([FromRoute] string projectKey, [FromRoute] string itemKey, [FromBody] UpsertItemParams ps)
        {
            if (!itemKey.Split(".")[0].Equals(projectKey, StringComparison.OrdinalIgnoreCase))
            {
                return(BadRequest("The item id should be started with it's project id."));
            }

            if (!await _permissionService.HasProjectPermissionAsync(projectKey, Permission.Admin))
            {
                return(StatusCode(403, "You have no permission to edit this item."));
            }

            ps.ProjectKey = projectKey;
            ps.ItemKey    = itemKey;
            return(Ok(await _itemService.UpdateItemAsync(ps)));
        }