Esempio n. 1
0
        private void UpdateMain(PriceProject model, string fieldName, string fieldValue, string userId, string fieldDisplay)
        {
            var property = model.GetType().GetProperty(fieldName);

            if (property != null)
            {
                var t = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType;

                object safeValue;
                if (string.IsNullOrEmpty(fieldValue))
                {
                    fieldValue = null;
                }
                if (t == typeof(Guid))
                {
                    safeValue = fieldValue == null ? null : Convert.ChangeType(new Guid(fieldValue), t);
                }
                else
                {
                    safeValue = fieldValue == null ? null : Convert.ChangeType(fieldValue, t);
                }
                property.SetValue(model, safeValue, null);
            }
            SaveHistoryField(model.Id, fieldName, fieldValue, new Guid(userId), fieldDisplay);
            //var subUpdateField = new SubUpdateField();
            //subUpdateField.ModelId = model.ObjectId;
            //return subUpdateField;
        }
Esempio n. 2
0
        public void UpdateModel(string code, string modelId, string userId, long?recordId, string fieldName, string fieldValue, string fieldDisplay)
        {
            PriceProject model = GetById(modelId);

            if (model == null)
            {
                return;
            }

            switch (code)
            {
            case "main": {
                UpdateMain(model, fieldName, fieldValue, userId, fieldDisplay);
                break;
            }
            }
            //return null;
        }