Beispiel #1
0
        public IEnumerable <ODataEntityDto> Handle(IOperationContext context, ODataEntityDto incomingODataEntity)
        {
            IEntity createdEntity;

            if (this.TryHandlePostInContainedNavigationProperty(context, incomingODataEntity, out createdEntity))
            {
                return(context.CreatePatchOrPostResponse(createdEntity, this.dtoBuilderFactory).Enumerate());
            }

            if (this.TryHandlePostInEntitySet(context, incomingODataEntity, out createdEntity))
            {
                return(context.CreatePatchOrPostResponse(createdEntity, this.dtoBuilderFactory).Enumerate());
            }

            throw new InvalidOperationException("The POST operation cannot be performed against the specified URL.");
        }
Beispiel #2
0
        public IEnumerable <ODataEntityDto> Handle(IOperationContext context, ODataEntityDto incomingODataEntity)
        {
            var modelContext = context.ModelContext.As <IBindableModelContext>();

            var entityToPatch = this.entityReader.ReadEntitiesFromPath(modelContext, context.Path).SingleOrDefault();

            if (entityToPatch == null)
            {
                throw new KeyNotFoundException("The specified entity could not be found.");
            }

            this.entityUpdater.UpdateEntity(modelContext, context.NavigationRoot, entityToPatch, incomingODataEntity);
            return(context.CreatePatchOrPostResponse(entityToPatch, this.dtoBuilderFactory).Enumerate());
        }