Example #1
0
        public async Task Update(ObjectValueContract objectValue)
        {
            objectContext = new ObjectContext();

            ObjectValue mongoEntity = objectValue.ToMongoEntity();
            await objectContext.ObjectValues.ReplaceOneAsync(Builders <ObjectValue> .Filter.Eq("Id", objectValue.Id), mongoEntity);
        }
Example #2
0
        public static ObjectValue ToMongoEntity(this ObjectValueContract objectValue)
        {
            ObjectValue ret = new ObjectValue
            {
                Id             = objectValue.Id,
                ObjectConfigId = objectValue.ObjectConfigId,
            };

            Dictionary <Guid, object> properties = new Dictionary <Guid, object>();

            foreach (var item in objectValue.Properties)
            {
                if (item.Value is Newtonsoft.Json.Linq.JArray)
                {
                    properties[item.Key] = ((Newtonsoft.Json.Linq.JArray)item.Value).ToObject <string[]>();
                }
                properties[item.Key] = item.Value;
            }
            ret.Properties = properties;

            return(ret);
        }
Example #3
0
 public async Task Create(ObjectValueContract objectValue)
 {
     objectContext = new ObjectContext();
     await objectContext.ObjectValues.InsertOneAsync(objectValue.ToMongoEntity());
 }