Esempio n. 1
0
        public object Put(CommunityUpdateRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            try {
                context.Open();
                if (string.IsNullOrEmpty(request.Identifier))
                {
                    throw new Exception("Invalid request - missing community identifier");
                }

                context.LogInfo(this, string.Format("/community PUT Identifier='{0}'", request.Identifier));

                ThematicCommunity domain = ThematicCommunity.FromIdentifier(context, request.Identifier);

                if (!domain.CanUserManage(context.UserId))
                {
                    throw new UnauthorizedAccessException("Action only allowed to manager of the domain");
                }

                domain = request.ToEntity(context, domain);
                domain.Store();

                domain.UpdateAppsLinks(request.Apps);
                domain.UpdateDomainsLinks(domain.Links);

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(new WebResponseBool(true));
        }