public ActionResult Create(OrganisationUpdateInput createInput)
        {
            if (ModelState.IsValid)
            {
                _messageBus.Send(
                    new OrganisationCreateCommand()
                {
                    UserId       = _userContext.GetAuthenticatedUserId(),
                    Name         = createInput.Name,
                    Description  = createInput.Description,
                    Website      = createInput.Website,
                    AvatarId     = createInput.AvatarId,
                    BackgroundId = createInput.BackgroundId,
                    Categories   = createInput.Categories
                });
            }
            else
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
            }

            dynamic viewModel = new ExpandoObject();

            viewModel.Organisation = createInput;

            return(RestfulResult(
                       viewModel,
                       "organisations",
                       "create"));
        }
        public ActionResult Update(OrganisationUpdateInput updateInput)
        {
            string organisationId = VerbosifyId <Organisation>(updateInput.Id);

            if (!_permissionManager.DoesExist <Organisation>(organisationId))
            {
                return(HttpNotFound());
            }

            if (!_userContext.HasGroupPermission <Organisation>(PermissionNames.UpdateOrganisation, organisationId))
            {
                return(new HttpUnauthorizedResult());
            }

            if (ModelState.IsValid)
            {
                _messageBus.Send(
                    new OrganisationUpdateCommand()
                {
                    UserId       = _userContext.GetAuthenticatedUserId(),
                    Id           = organisationId,
                    Name         = updateInput.Name,
                    Description  = updateInput.Description,
                    Website      = updateInput.Website,
                    AvatarId     = updateInput.AvatarId,
                    BackgroundId = updateInput.BackgroundId,
                    Categories   = updateInput.Categories
                });
            }
            else
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
            }

            dynamic viewModel = new ExpandoObject();

            viewModel.Organisation = updateInput;

            return(RestfulResult(
                       viewModel,
                       "organisations",
                       "update"));
        }
        public ActionResult Update(OrganisationUpdateInput updateInput)
        {
            string organisationId = VerbosifyId<Organisation>(updateInput.Id);

            if (!_permissionManager.DoesExist<Organisation>(organisationId))
            {
                return HttpNotFound();
            }

            if (!_userContext.HasGroupPermission<Organisation>(PermissionNames.UpdateOrganisation, organisationId))
            {
                return new HttpUnauthorizedResult();
            }

            if (ModelState.IsValid)
            {
                _messageBus.Send(
                    new OrganisationUpdateCommand()
                    {
                        UserId = _userContext.GetAuthenticatedUserId(),
                        Id = organisationId,
                        Name = updateInput.Name,
                        Description = updateInput.Description,
                        Website = updateInput.Website,
                        AvatarId = updateInput.AvatarId,
                        BackgroundId = updateInput.BackgroundId,
                        Categories = updateInput.Categories
                    });
            }
            else
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
            }

            dynamic viewModel = new ExpandoObject();
            viewModel.Organisation = updateInput;

            return RestfulResult(
                viewModel,
                "organisations",
                "update");
        }
        public ActionResult Create(OrganisationUpdateInput createInput)
        {
            if (ModelState.IsValid)
            {
                _messageBus.Send(
                    new OrganisationCreateCommand()
                        {
                            UserId = _userContext.GetAuthenticatedUserId(),
                            Name = createInput.Name,
                            Description = createInput.Description,
                            Website = createInput.Website,
                            AvatarId = createInput.AvatarId,
                            BackgroundId = createInput.BackgroundId,
                            Categories = createInput.Categories
                        });
            }
            else
            {
                Response.StatusCode = (int) System.Net.HttpStatusCode.BadRequest;
            }

            dynamic viewModel = new ExpandoObject();
            viewModel.Organisation = createInput;

            return RestfulResult(
                viewModel,
                "organisations",
                "create");
        }