Example #1
0
 internal void SetAssociation(INakedObject nakedObject, IOneToOneAssociation oneToOneAssoc, INakedObject valueNakedObject, object attemptedValue) {
     IConsent consent = oneToOneAssoc.IsAssociationValid(nakedObject, valueNakedObject);
     string key = IdHelper.GetFieldInputId(nakedObject, oneToOneAssoc);
     if (consent.IsAllowed) {
         oneToOneAssoc.SetAssociation(nakedObject, valueNakedObject);
     }
     else {
         ModelState.AddModelError(key, consent.Reason);
     }
     AddAttemptedValue(key, attemptedValue);
 }
Example #2
0
        internal void ValidateAssociation(INakedObject nakedObject, IOneToOneAssociation oneToOneAssoc, object attemptedValue, INakedObjectAssociation parent = null) {
            string key = GetFieldInputId(parent, nakedObject, oneToOneAssoc);
            try {
                INakedObject valueNakedObject = GetNakedObjectValue(oneToOneAssoc, nakedObject, attemptedValue);

                IConsent consent = oneToOneAssoc.IsAssociationValid(nakedObject, valueNakedObject);               
                if (!consent.IsAllowed) {
                    ModelState.AddModelError(key, consent.Reason);
                }
            }
            catch (InvalidEntryException) {
                ModelState.AddModelError(key, MvcUi.InvalidEntry);
            }
            catch (ArgumentException) {
                // Always expect newValue to be non-null for a parseable field as it should always be included 
                // in the form so this is an unexpected result for a parseable field 
                ModelState.AddModelError(key, MvcUi.InvalidEntry);
            }
            finally {
                AddAttemptedValue(key, attemptedValue);
            }
        }
Example #3
0
 public void SetValue(IOneToOneAssociation field, object obj) {}