示例#1
0
        public HttpResponseMessage Update(Facade.SubscriptionPut subscriptionPut)
        {
            return(ProcessPut(() =>
            {
                var current = entityById.Get <Subscription>(subscriptionPut.Id.ToModel());

                current.Callback = subscriptionPut.Callback.ToModel();
                updateCommand.Execute(current);
            }));
        }
示例#2
0
        public HttpResponseMessage History(Identity topicId, Identity feedId)
        {
            var workingFeed     = entityById.Get <Feed>(feedId);
            var syndicationFeed = CreateSyndicationFromFeed(topicId, workingFeed);

            return(new HttpResponseMessage <SyndicationFeed>(syndicationFeed, HttpStatusCode.OK)
            {
                Content = { Headers = { ContentType = new MediaTypeHeaderValue("application/atom+xml") } }
            });
        }
示例#3
0
        public ActionResult Edit(string id)
        {
            var identity = new Identity(id);
            var entity   = entityById.Get <Topic>(identity);

            if (entity == null)
            {
                return(new HttpStatusCodeResult(404));
            }
            var model = new EditTopicModel(entity, groupsSortedByName.Execute());

            return(View(model));
        }
示例#4
0
        public ActionResult Edit(string id)
        {
            var groupId = new Identity(id);
            var group   = entityById.Get <Group>(groupId);

            if (group == null)
            {
                return(View("GroupDoesNotExist"));
            }


            var model = new GroupEditModel
            {
                Group = new GroupModel
                {
                    Id          = group.Id.ToString(),
                    Name        = group.Name,
                    Description = group.Description,
                    ParentId    = group.ParentId.ToString()
                },
                GroupList = GetGroupList(groupId)
            };

            return(View(model));
        }
示例#5
0
        private void ValidateCircleReferences(Group group)
        {
            var parentsId       = new HashSet <Identity>();
            var currentParentId = group.ParentId;

            while (currentParentId.HasValue)
            {
                if (!parentsId.Add(currentParentId.Value))
                {
                    break;
                }
                currentParentId = entityById.Get <Group>(currentParentId.Value).ParentId;
            }

            if (parentsId.Contains(group.Id.Value))
            {
                throw new ValidationException(string.Format(Texts.GroupCircleReference, group.Id));
            }
        }
示例#6
0
        public IEnumerable <MessageKey> Get(Identity subscriptionId, Identity?last = null, int?skip = null, int?limit = null)
        {
            var subscription = entityById.Get <Subscription>(subscriptionId);

            if (subscription != null)
            {
                switch (subscription.TargetKind)
                {
                case TargetKind.Topic:
                    return(messageByTopic.Get(subscription.TargetId.Value, last, skip, limit));

                case TargetKind.Group:
                    return(messageByGroup.Get(subscription.TargetId.Value, last, skip, limit));

                default:
                    throw new InvalidOperationException(string.Format(Texts.TargetKindUnknown,
                                                                      subscription.TargetKind));
                }
            }

            return(new MessageKey[0]);
        }
示例#7
0
 public HttpResponseMessage <Facade.Group> Get(Identity id)
 {
     return(ProcessGet(() => entityById.Get <Group>(id).ToFacade()));
 }
示例#8
0
 public HttpResponseMessage <Topic> Get(Identity id)
 {
     return(ProcessGet(() => entityById.Get <M.Topic>(id.ToModel()).ToFacade()));
 }