Inheritance: IValidationConcept
        private static string CheckChangesOnInsertSnippet(DenyUserEditPropertyInfo info)
        {
            return string.Format(
            @"if (checkUserPermissions)
            {{
                var invalidItem = insertedNew.Where(newItem => newItem.{3} != null).FirstOrDefault();

                {4}
            }}

            ",
                info.Property.DataStructure.Module.Name,
                info.Property.DataStructure.Name,
                info.Property.Name,
                GetComparedPropertyName(info.Property),
                ThrowExceptionSnippet(info));
        }
        private static string CheckChangesOnUpdateSnippet(DenyUserEditPropertyInfo info)
        {
            return string.Format(
            @"if (checkUserPermissions)
            {{
                var changes = updatedNew.Zip(updated, (newItem, oldItem) => new {{ newItem, oldItem }});
                foreach (var change in changes)
                    if (change.newItem.{3} == null && change.oldItem.{3} != null)
                        change.newItem.{3} = change.oldItem.{3};
                var invalidItem = changes
                    .Where(change => change.newItem.{3} != null && !change.newItem.{3}.Equals(change.oldItem.{3}) || change.newItem.{3} == null && change.oldItem.{3} != null)
                    .Select(change => change.newItem)
                    .FirstOrDefault();

                {4}
            }}

            ",
                info.Property.DataStructure.Module.Name,
                info.Property.DataStructure.Name,
                info.Property.Name,
                GetComparedPropertyName(info.Property),
                ThrowExceptionSnippet(info));
        }
 private static string ThrowExceptionSnippet(DenyUserEditPropertyInfo info)
 {
     return string.Format(
     @"if (invalidItem != null)
             throw new Rhetos.UserException(
                 ""It is not allowed to directly enter {{0}} property of {{1}}."",
                 new[] {{ ""{2}"", ""{0}.{1}"" }},
                 ""DataStructure:{0}.{1},ID:"" + invalidItem.ID + "",Property:{2}"",
                 null);
     ",
         info.Property.DataStructure.Module.Name,
         info.Property.DataStructure.Name,
         info.Property.Name,
         GetComparedPropertyName(info.Property));
 }