Example #1
0
 protected virtual bool BaseSave(bool force)
 {
     if ((this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.ToBeDeleted))
     {
         this.Delete();
         return(false);
     }
     CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saving, true);
     this.OnEntityAction(evt);
     if ((evt.Cancel == true))
     {
         return(false);
     }
     CodeFluentPersistence.ThrowIfDeleted(this);
     this.Validate();
     if (((force == false) &&
          (this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.Unchanged)))
     {
         return(false);
     }
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(DigitalPicnik.Constants.DigitalPicnikStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "List", "Save");
     persistence.AddParameter("@List_Id", this.Id, CodeFluentPersistence.DefaultGuidValue);
     persistence.AddParameter("@List_Title", this.Title, default(string));
     persistence.AddParameter("@List_Description", this.Description, default(string));
     persistence.AddParameter("@_trackLastWriteUser", persistence.Context.User.Name);
     persistence.AddParameter("@_rowVersion", this.RowVersion);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             this.ReadRecordOnSave(reader);
         }
         CodeFluentPersistence.NextResults(reader);
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saved, false, false));
     this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
     return(true);
 }
Example #2
0
 protected virtual bool BaseSave(bool force)
 {
     if ((this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.ToBeDeleted))
     {
         this.Delete();
         return(false);
     }
     CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saving, true);
     this.OnEntityAction(evt);
     if ((evt.Cancel == true))
     {
         return(false);
     }
     CodeFluentPersistence.ThrowIfDeleted(this);
     this.Validate();
     if (((force == false) &&
          (this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.Unchanged)))
     {
         return(false);
     }
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.AspNetIdentity1.Constants.SoftFluent_Samples_AspNetIdentity1StoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "ExternalLogin", "Save");
     persistence.AddParameter("@ExternalLogin_ProviderKey", this.ProviderKey, default(string));
     persistence.AddParameter("@ExternalLogin_ProviderName", this.ProviderName, default(string));
     persistence.AddParameter("@ExternalLogin_User_Id", this.UserId, default(string));
     persistence.AddParameter("@_trackLastWriteUser", persistence.Context.User.Name);
     persistence.AddParameter("@_rowVersion", this.RowVersion);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             this.ReadRecordOnSave(reader);
         }
         CodeFluentPersistence.NextResults(reader);
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saved, false, false));
     this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
     return(true);
 }
Example #3
0
 protected virtual bool BaseSave(bool force)
 {
     if ((this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.ToBeDeleted))
     {
         this.Delete();
         return(false);
     }
     CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saving, true);
     this.OnEntityAction(evt);
     if ((evt.Cancel == true))
     {
         return(false);
     }
     CodeFluentPersistence.ThrowIfDeleted(this);
     this.Validate();
     if (((force == false) &&
          (this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.Unchanged)))
     {
         return(false);
     }
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.SqlServerInMemory.Constants.SoftFluent_SqlServerInMemoryStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Customer", "Save");
     persistence.AddParameter("@Customer_Id", this.Id, CodeFluentPersistence.DefaultGuidValue);
     persistence.AddParameter("@Customer_Name", this.Name, default(string));
     persistence.AddParameter("@Customer_ContactSource_Id", this.ContactSourceId, ((int)(-1)));
     persistence.AddParameter("@_trackLastWriteUser", persistence.Context.User.Name);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             this.ReadRecordOnSave(reader);
         }
         CodeFluentPersistence.NextResults(reader);
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saved, false, false));
     this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
     return(true);
 }
Example #4
0
 public virtual void Validate(System.Globalization.CultureInfo culture, System.Collections.Generic.IList <CodeFluent.Runtime.CodeFluentValidationException> results)
 {
     CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Validating, true, results);
     evt.Culture = culture;
     this.OnEntityAction(evt);
     if ((evt.Cancel == true))
     {
         string externalValidate;
         if ((evt.Argument != null))
         {
             externalValidate = evt.Argument.ToString();
         }
         else
         {
             externalValidate = SoftFluent.Samples.Thinktecture.IdentityServer.Resources.Manager.GetStringWithDefault(culture, "SoftFluent.Samples.Thinktecture.IdentityServer.Login.ExternalValidate", "Type \'SoftFluent.Samples.Thinktecture.IdentityServer.Login\' cannot be validated.", null);
         }
         CodeFluentPersistence.AddValidationError(results, externalValidate);
     }
     CodeFluentPersistence.ValidateMember(culture, results, this, null);
     if ((this.Id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         string localValidate = SoftFluent.Samples.Thinktecture.IdentityServer.Resources.Manager.GetStringWithDefault(culture, "SoftFluent.Samples.Thinktecture.IdentityServer.Login.Id.NullException", "\'Id\' property cannot be set to \'00000000-0000-0000-0000-000000000000\' for type \'S" +
                                                                                                                      "oftFluent.Samples.Thinktecture.IdentityServer.Login\'", null);
         CodeFluentPersistence.AddValidationError(results, localValidate);
     }
     if ((this.ProviderName == default(string)))
     {
         string localValidate1 = SoftFluent.Samples.Thinktecture.IdentityServer.Resources.Manager.GetStringWithDefault(culture, "SoftFluent.Samples.Thinktecture.IdentityServer.Login.ProviderName.NullException", "\'ProviderName\' property cannot be set to \'\' for type \'SoftFluent.Samples.Thinktec" +
                                                                                                                       "ture.IdentityServer.Login\'", null);
         CodeFluentPersistence.AddValidationError(results, localValidate1);
     }
     if ((this.ProviderKey == default(string)))
     {
         string localValidate2 = SoftFluent.Samples.Thinktecture.IdentityServer.Resources.Manager.GetStringWithDefault(culture, "SoftFluent.Samples.Thinktecture.IdentityServer.Login.ProviderKey.NullException", "\'ProviderKey\' property cannot be set to \'\' for type \'SoftFluent.Samples.Thinktect" +
                                                                                                                       "ure.IdentityServer.Login\'", null);
         CodeFluentPersistence.AddValidationError(results, localValidate2);
     }
     if ((this.User == null))
     {
         string localValidate3 = SoftFluent.Samples.Thinktecture.IdentityServer.Resources.Manager.GetStringWithDefault(culture, "SoftFluent.Samples.Thinktecture.IdentityServer.Login.User.NullException", "\'User\' property cannot be set to \'\' for type \'SoftFluent.Samples.Thinktecture.Ide" +
                                                                                                                       "ntityServer.Login\'", null);
         CodeFluentPersistence.AddValidationError(results, localValidate3);
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Validated, false, results));
 }
Example #5
0
 public virtual void Validate(System.Globalization.CultureInfo culture, System.Collections.Generic.IList <CodeFluent.Runtime.CodeFluentValidationException> results)
 {
     CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Validating, true, results);
     evt.Culture = culture;
     this.OnEntityAction(evt);
     if ((evt.Cancel == true))
     {
         string externalValidate;
         if ((evt.Argument != null))
         {
             externalValidate = evt.Argument.ToString();
         }
         else
         {
             externalValidate = SoftFluent.Json.NET.Resources.Manager.GetStringWithDefault(culture, "SoftFluent.Json.NET.Publication.ExternalValidate", "Type \'SoftFluent.Json.NET.Publication\' cannot be validated.", null);
         }
         CodeFluentPersistence.AddValidationError(results, externalValidate);
     }
     CodeFluentPersistence.ValidateMember(culture, results, this, null);
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Validated, false, results));
 }
Example #6
0
 public virtual void Validate(System.Globalization.CultureInfo culture, System.Collections.Generic.IList <CodeFluent.Runtime.CodeFluentValidationException> results)
 {
     CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Validating, true, results);
     evt.Culture = culture;
     this.OnEntityAction(evt);
     if ((evt.Cancel == true))
     {
         string externalValidate;
         if ((evt.Argument != null))
         {
             externalValidate = evt.Argument.ToString();
         }
         else
         {
             externalValidate = ModelCodeFluent.Resources.Manager.GetStringWithDefault(culture, "ModelCodeFluent.Identity.RoleClaim.ExternalValidate", "Type \'ModelCodeFluent.Identity.RoleClaim\' cannot be validated.", null);
         }
         CodeFluentPersistence.AddValidationError(results, externalValidate);
     }
     CodeFluentPersistence.ValidateMember(culture, results, this, null);
     if ((this.Id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         string localValidate = ModelCodeFluent.Resources.Manager.GetStringWithDefault(culture, "ModelCodeFluent.Identity.RoleClaim.Id.NullException", "\'Id\' property cannot be set to \'00000000-0000-0000-0000-000000000000\' for type \'M" +
                                                                                       "odelCodeFluent.Identity.RoleClaim\'", null);
         CodeFluentPersistence.AddValidationError(results, localValidate);
     }
     if ((this.Type == default(string)))
     {
         string localValidate1 = ModelCodeFluent.Resources.Manager.GetStringWithDefault(culture, "ModelCodeFluent.Identity.RoleClaim.Type.NullException", "\'Type\' property cannot be set to \'\' for type \'ModelCodeFluent.Identity.RoleClaim\'" +
                                                                                        "", null);
         CodeFluentPersistence.AddValidationError(results, localValidate1);
     }
     if ((this.Role == null))
     {
         string localValidate2 = ModelCodeFluent.Resources.Manager.GetStringWithDefault(culture, "ModelCodeFluent.Identity.RoleClaim.Role.NullException", "\'Role\' property cannot be set to \'\' for type \'ModelCodeFluent.Identity.RoleClaim\'" +
                                                                                        "", null);
         CodeFluentPersistence.AddValidationError(results, localValidate2);
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Validated, false, results));
 }
Example #7
0
        public virtual bool Delete()
        {
            bool ret = false;

            CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Deleting, true);
            this.OnEntityAction(evt);
            if ((evt.Cancel == true))
            {
                return(ret);
            }
            if ((this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.Deleted))
            {
                return(ret);
            }
            CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.SqlServerInMemory.Constants.SoftFluent_SqlServerInMemoryStoreName).Persistence;
            persistence.CreateStoredProcedureCommand(null, "Customer", "Delete");
            persistence.AddParameter("@Customer_Id", this.Id, CodeFluentPersistence.DefaultGuidValue);
            persistence.ExecuteNonQuery();
            this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Deleted;
            this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Deleted, false, false));
            ret = true;
            return(ret);
        }