Пример #1
0
        public IActionResult RenameContent([FromBody] RenameContentRequest request)
        {
            try
            {
                var userId = Int32.Parse(User.Identity.Name);
                _userManagementService.CheckUserExists(userId);

                _contentManagementService.RenameContent(request.ContentId, request.NewName);

                return(Ok());
            }
            catch (UserNotExistError)
            {
                return(StatusCode(StatusCodes.Status404NotFound, new
                {
                    message = "Пользователь не найден"
                }));
            }
            catch (ContentNotExistError)
            {
                return(StatusCode(StatusCodes.Status404NotFound, new
                {
                    message = "Материал не найден"
                }));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new { message = e.Message }));
            }
        }