Exemple #1
0
        public async Task <IActionResult> AddGroupToFile(string fileKey, [FromBody] AddGroupToFileRequest request)
        {
            try
            {
                var  userKey           = _contextAccessor.UserKeyFromContext();
                bool userCanAccessFile = await UserCanAccessFile(userKey, fileKey, _hiarcDatabase, AccessLevelGroup.CoOwner);

                if (userCanAccessFile)
                {
                    await _hiarcDatabase.AddGroupToFile(fileKey, request);

                    return(Ok(new Empty()));
                }
                else
                {
                    return(StatusCode(StatusCodes.Status403Forbidden));
                }
            }
            catch (ArgumentException argEx)
            {
                return(BuildErrorResponse(argEx, _logger, StatusCodes.Status400BadRequest));
            }
            catch (Exception ex)
            {
                return(BuildErrorResponse(ex, _logger));
            }
        }