Esempio n. 1
0
        public void Post(string classCode, [FromBody] JObject obj)
        {
            Class             @class            = this.GetValidatedClass(classCode);
            ObjectManipulator objectManipulator = new ObjectManipulator(this);

            objectManipulator.BeginCreateTransaction(classCode);

            foreach (JProperty property in obj.Properties())
            {
                try
                {
                    objectManipulator.SetPropertyValue(property.Name, property.Value);
                }

                catch (System.ArgumentException e)
                {
                    throw new HttpException(400, e.Message);
                }
            }

            int    objectId = objectManipulator.CommitTransaction();
            Object @object  = this.Storage.GetRepository <IObjectRepository>().WithKey(objectId);

            Event <IObjectCreatedEventHandler, IRequestHandler, Object> .Broadcast(this, @object);
        }
Esempio n. 2
0
        public void Put(string classCode, int id, [FromBody] JObject @object)
        {
            ObjectManipulator objectManipulator = new ObjectManipulator(this);

            objectManipulator.BeginEditTransaction(classCode, id);

            foreach (JProperty property in @object.Properties())
            {
                objectManipulator.SetPropertyValue(property.Name, property.Value);
            }

            objectManipulator.CommitTransaction();
        }
Esempio n. 3
0
        public void Post(string classCode, [FromBody] JObject obj)
        {
            Class             @class            = this.GetValidatedClass(classCode);
            ObjectManipulator objectManipulator = new ObjectManipulator(this);

            objectManipulator.BeginCreateTransaction(classCode);

            foreach (JProperty property in obj.Properties())
            {
                try
                {
                    objectManipulator.SetPropertyValue(property.Name, property.Value);
                }

                catch (System.ArgumentException e)
                {
                    throw new HttpException(400, e.Message);
                }
            }

            objectManipulator.CommitTransaction();
        }
Esempio n. 4
0
        public void Put(string classCode, int id, [FromBody] JObject obj)
        {
            Class             @class            = this.GetValidatedClass(classCode);
            Object            @object           = this.GetValidatedObject(@class, id);
            ObjectManipulator objectManipulator = new ObjectManipulator(this);

            objectManipulator.BeginEditTransaction(classCode, id);

            foreach (JProperty property in obj.Properties())
            {
                try
                {
                    objectManipulator.SetPropertyValue(property.Name, property.Value);
                }

                catch (System.ArgumentException e)
                {
                    throw new HttpException(400, e.Message);
                }
            }

            objectManipulator.CommitTransaction();
            Event <IObjectEditedEventHandler, IRequestHandler, Object> .Broadcast(this, @object);
        }