Exemplo n.º 1
0
 public Field(FieldDataModel model)
 {
     Type  = model.Type;
     Name  = model.Name != null ? new CipherString(model.Name) : null;
     Value = model.Value != null ? new CipherString(model.Value) : null;
 }
Exemplo n.º 2
0
        public IHttpActionResult PostVerify(IEnumerable <JObject> AssetObjs)
        {
            //dddd
            var         ChildOne    = AssetObjs.FirstOrDefault <JObject>();
            var         parentID    = Int32.Parse(ChildOne["ParentAssetID"].ToString());
            FieldParent fieldParent = new FieldParent()
            {
                ParentID = parentID
            };

            foreach (var AssetObj in AssetObjs)
            {
                var ParentAssetID = Int32.Parse(AssetObj["ParentAssetID"].ToString());
                var ChildID       = Int32.Parse(AssetObj["ChildID"].ToString());
                var lat           = (Decimal)AssetObj["latitude"];
                var log           = (Decimal)AssetObj["longitude"];

                var username = AssetObj["username"].ToString();

                var UserID = context.UserModel.Where(x => x.Username == username).FirstOrDefault <UserModel>().UserId;


                //store in the asset model
                AssetModel assetModel = new AssetModel()
                {
                    //SiteID = SiteID,
                    //UniqueIdentifier = uniqueIdentifier,
                    ParentAssetID = ParentAssetID,
                    ChildID       = ChildID
                };

                //storing the properties value into the dB
                var Properties = AssetObj["Properties"];
                foreach (var property in Properties)
                {
                    PropertyValue prop = new PropertyValue()
                    {
                        AssetID       = assetModel.AssetID,
                        ParentAssetID = ParentAssetID,
                        ChildID       = ChildID,
                        PropertyID    = Int32.Parse(property["PropertyID"].ToString()),
                        Value         = property["Value"]["Name"].ToString(),
                        //OptionID = Int32.Parse(property["Value"]["OptionID"].ToString()),
                    };
                    context.PropertyValue.Add(prop);
                }

                //Field Data
                FieldDataModel fieldData = new FieldDataModel()
                {
                    AssetID       = assetModel.AssetID,
                    Latitude      = lat,
                    Longitude     = log,
                    ParentAssetID = ParentAssetID,
                    ChildID       = ChildID,
                    UserID        = UserID
                };


                context.AssetModel.Add(assetModel);
                context.FieldDataModel.Add(fieldData);

                context.SaveChanges();
            }
            context.FieldParent.Add(fieldParent);
            context.SaveChanges();
            return(Ok());
        }
Exemplo n.º 3
0
 public Field(FieldDataModel model)
 {
     Type  = model.Type;
     Name  = new CipherString(model.Name);
     Value = new CipherString(model.Value);
 }