public static bool ContainsRule(Csla.Core.BusinessBase obj, DbType type, string propertyName) { switch (type) { case DbType.Int16: case DbType.Int32: case DbType.Int64: return(obj.BrokenRulesCollection.Any( brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.data.validation.integerrequired/{0}", propertyName))); case DbType.Decimal: return(obj.BrokenRulesCollection.Any( brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.data.validation.decimalrequired/{0}", propertyName))); case DbType.DateTime: return(obj.BrokenRulesCollection.Any( brokenRule => brokenRule.RuleName == string.Format("rule://epiworx.data.validation.datetimerequired/{0}", propertyName))); case DbType.String: case DbType.StringFixedLength: return(obj.BrokenRulesCollection.Any( brokenRule => brokenRule.RuleName == string.Format("rule://csla.rules.commonrules.required/{0}", propertyName)) || obj.BrokenRulesCollection.Any( brokenRule => brokenRule.RuleName == string.Format("rule://csla.rules.commonrules.dataannotation/{0}?a=System.ComponentModel.DataAnnotations.RequiredAttribute", propertyName))); default: throw new NotSupportedException(); } }
public static bool HasNewItem <T>(System.Collections.Generic.IEnumerable <T> list) where T : Csla.Core.BusinessBase { bool flag; using (System.Collections.Generic.IEnumerator <T> ienumerator = list.GetEnumerator()) { while (ienumerator.MoveNext()) { Csla.Core.BusinessBase businessBase = ienumerator.Current; if (businessBase.IsNew) { flag = true; return(flag); } } } return(false); }
/// <summary> /// By wrapping this property inside Using block /// you can set property values on /// <paramref name="businessObject">business object</paramref> /// without raising PropertyChanged events /// and checking user rights. /// </summary> /// <param name="businessObject"> /// Object on with you would like to set property values /// </param> /// <returns> /// An instance of IDisposable object that allows /// bypassing of normal authorization checks during /// property setting. /// </returns> protected IDisposable BypassPropertyChecks(Csla.Core.BusinessBase businessObject) { return(businessObject.BypassPropertyChecks); }
/// <summary> /// Called by the business object's Save() method to /// insert, update or delete an object in the database. /// </summary> /// <remarks> /// Note that this method returns a reference to the updated business object. /// If the server-side DataPortal is running remotely, this will be a new and /// different object from the original, and all object references MUST be updated /// to use this new object. /// </remarks> /// <param name="obj">A reference to the business object to be updated.</param> /// <returns>A reference to the updated business object.</returns> public static object Update(object obj) { Server.DataPortalResult result; MethodInfo method; string methodName; if (obj is CommandBase) { methodName = "DataPortal_Execute"; } else if (obj is Core.BusinessBase) { Core.BusinessBase tmp = (Core.BusinessBase)obj; if (tmp.IsDeleted) { methodName = "DataPortal_DeleteSelf"; } else if (tmp.IsNew) { methodName = "DataPortal_Insert"; } else { methodName = "DataPortal_Update"; } } else { methodName = "DataPortal_Update"; } method = MethodCaller.GetMethod(obj.GetType(), methodName); DataPortalClient.IDataPortalProxy proxy; proxy = GetDataPortalProxy(RunLocal(method)); Server.DataPortalContext dpContext = new Server.DataPortalContext(GetPrincipal(), proxy.IsServerRemote); OnDataPortalInvoke(new DataPortalEventArgs(dpContext)); try { result = proxy.Update(obj, dpContext); } catch (Server.DataPortalException ex) { result = ex.Result; if (proxy.IsServerRemote) { ApplicationContext.SetGlobalContext(result.GlobalContext); } throw new DataPortalException( String.Format("DataPortal.Update {0} ({1})", Resources.Failed, ex.InnerException.InnerException), ex.InnerException, result.ReturnObject); } if (proxy.IsServerRemote) { ApplicationContext.SetGlobalContext(result.GlobalContext); } OnDataPortalInvokeComplete(new DataPortalEventArgs(dpContext)); return(result.ReturnObject); }
public static bool ContainsRule(Csla.Core.BusinessBase obj, string name) { return(obj.BrokenRulesCollection.Any( brokenRule => brokenRule.RuleName == name)); }