private NOKEntity Update(NOKEntity nok) { if (nok == null) { throw new ArgumentNullException("nok"); } string userName = IdentityUser.GetIdentityUserName(); using (TransactionScope scope = new TransactionScope()) { if (nok.Person.EditStatus.Value == StatusEntityValue.Updated) { nok.Person = base.InnerUpdate(nok.Person, userName, true); } this.InnerUpdate(nok, userName); scope.Complete(); } this.ResetNOK(nok); LOPDLogger.Write(EntityNames.NOKEntityName, nok.ID, ActionType.Modify); return(nok); }
private NOKEntity Insert(NOKEntity nok) { if (nok == null) { throw new ArgumentNullException("nok"); } string userName = IdentityUser.GetIdentityUserName(); int categoryID = _categoryDA.GetCategoryIDByCategoryKey((int)CategoryPersonKeyEnum.NOK); if (categoryID <= 0) { throw new Exception(Properties.Resources.ERROR_NoCategoryDefinedForNOKs); } using (TransactionScope scope = new TransactionScope()) { this.InnerInsert(nok, userName, categoryID); scope.Complete(); } this.ResetNOK(nok); LOPDLogger.Write(EntityNames.NOKEntityName, nok.ID, ActionType.Create); return(nok); }
private CustomerContactPersonEntity Update(CustomerContactPersonEntity customerContactPerson) { if (customerContactPerson == null) { throw new ArgumentNullException("customerContactPerson"); } string userName = IdentityUser.GetIdentityUserName(); using (TransactionScope scope = new TransactionScope()) { if (customerContactPerson.Person.EditStatus.Value == StatusEntityValue.Updated) { customerContactPerson.Person = base.InnerUpdate(customerContactPerson.Person, userName, true); } //else //{ // customerContactPerson.Person = base.InnerUpdate(customerContactPerson.Person, userName, false); //} this.InnerUpdate(customerContactPerson, userName); scope.Complete(); } this.ResetCustomerContactPerson(customerContactPerson); LOPDLogger.Write(EntityNames.CustomerContactPersonEntityName, customerContactPerson.ID, ActionType.Modify); return(customerContactPerson); }
private CustomerContactPersonEntity Insert(CustomerContactPersonEntity customerContactPerson) { if (customerContactPerson == null) { throw new ArgumentNullException("customerContactPerson"); } string userName = IdentityUser.GetIdentityUserName(); int categoryID = _categoryDA.GetCategoryIDByCategoryKey((int)CategoryPersonKeyEnum.CustContactPerson); if (categoryID <= 0) { throw new Exception(Properties.Resources.ERROR_NoCategoryDefinedForCustomerContactPersons); } using (TransactionScope scope = new TransactionScope()) { this.InnerInsert(customerContactPerson, userName, categoryID); scope.Complete(); } this.ResetCustomerContactPerson(customerContactPerson); LOPDLogger.Write(EntityNames.CustomerContactPersonEntityName, customerContactPerson.ID, ActionType.Create); return(customerContactPerson); }
/* * public CustomerContactOrganizationEntity GetCustomerContactOrganization(int customerContactOrganizationID) * { * try * { * OrganizationBL organizationBL = new OrganizationBL(); * * DataSet ds = _customerContactOrganizationDA.GetCustomerContactOrganization(customerContactOrganizationID); * if ((ds.Tables != null) && (ds.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.CustomerContactOrganizationTable)) && (ds.Tables[SII.HCD.Administrative.Entities.TableNames.CustomerContactOrganizationTable].Rows.Count > 0)) * { * int organizationID = SIIConvert.ToInteger(ds.Tables[SII.HCD.Administrative.Entities.TableNames.CustomerContactOrganizationTable].Rows[0]["OrganizationID"].ToString(), 0); * int contactTypeID = SIIConvert.ToInteger(ds.Tables[SII.HCD.Administrative.Entities.TableNames.CustomerContactOrganizationTable].Rows[0]["ContactTypeID"].ToString(), 0); * * DataSet ds2; * #region Contact Types * ds2 = _contactTypeDA.GetContactTypeByID(contactTypeID); * if ((ds2 != null) && (ds2.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.ContactTypeTable))) * { * DataTable dt = ds2.Tables[SII.HCD.Administrative.Entities.TableNames.ContactTypeTable].Copy(); * ds.Tables.Add(dt); * } #endregion * #region Organization * if (organizationID <= 0) * { * throw new Exception(Properties.Resources.ERROR_CustomerContactOrganizationNotFound); * } * SII.HCD.BackOffice.Entities.OrganizationEntity myOrganization = organizationBL.GetOrganization(organizationID); #endregion * * CustomerContactOrganizationAdvancedAdapter customerContactOrganizationAdapter = new CustomerContactOrganizationAdvancedAdapter(); * CustomerContactOrganizationEntity result = customerContactOrganizationAdapter.GetInfo(ds.Tables[SII.HCD.Administrative.Entities.TableNames.CustomerContactOrganizationTable].Rows[0], ds); * result.Organization = myOrganization; * LOPDLogger.Write(EntityNames.CustomerContactOrganizationEntityName, customerContactOrganizationID, ActionType.View); * return result; * } * else * return null; * } * catch (Exception ex) * { * if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service)) throw; * return null; * } * } */ public CustomerContactOrganizationEntity GetCustomerContactOrganization(int customerContactOrganizationID) { try { OrganizationBL organizationBL = new OrganizationBL(); DataSet ds = _customerContactOrganizationDA.GetCustomerContactOrganization(customerContactOrganizationID); if ((ds.Tables != null) && (ds.Tables.Contains(Administrative.Entities.TableNames.CustomerContactOrganizationTable)) && (ds.Tables[Administrative.Entities.TableNames.CustomerContactOrganizationTable].Rows.Count > 0)) { int organizationID = SIIConvert.ToInteger(ds.Tables[Administrative.Entities.TableNames.CustomerContactOrganizationTable].Rows[0]["OrganizationID"].ToString(), 0); #region Organization if (organizationID <= 0) { throw new Exception(Properties.Resources.ERROR_CustomerContactOrganizationNotFound); } SII.HCD.BackOffice.Entities.OrganizationEntity myOrganization = null; var HiloOrganization = System.Threading.Tasks.Task.Factory.StartNew(() => myOrganization = organizationBL.GetOrganization(organizationID)); DataSet ds2 = new DataSet(); foreach (DataTable oTabla in ds.Tables) { if (oTabla.Rows.Count > 0) { ds2.Tables.Add(oTabla.Copy()); } } #endregion CustomerContactOrganizationAdvancedAdapter customerContactOrganizationAdapter = new CustomerContactOrganizationAdvancedAdapter(); CustomerContactOrganizationEntity result = customerContactOrganizationAdapter.GetInfo(ds.Tables[Administrative.Entities.TableNames.CustomerContactOrganizationTable].Rows[0], ds2); HiloOrganization.Wait(); result.Organization = myOrganization; LOPDLogger.Write(EntityNames.CustomerContactOrganizationEntityName, customerContactOrganizationID, ActionType.View); ds.Dispose(); ds2.Dispose(); return(result); } else { return(null); } } catch (Exception ex) { if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service)) { throw; } return(null); } }
/* * public NOKEntity GetNOK(int nokID) * { * try * { * NOKAdapter nokAdapter = new NOKAdapter(); * PersonBL personBL = new PersonBL(); * * DataSet ds = _nokDA.GetNOK(nokID); * if ((ds.Tables != null) && (ds.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.NOKTable)) && (ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows.Count > 0)) * { * int personID = SIIConvert.ToInteger(ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows[0]["PersonID"].ToString(), 0); * int kinshipID = SIIConvert.ToInteger(ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows[0]["KinshipID"].ToString(), 0); * * DataSet ds2; * #region Kinships * ds2 = _kinshipDA.GetKinshipByID(kinshipID); * if ((ds2 != null) && (ds2.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.KinshipTable))) * { * DataTable dt = ds2.Tables[SII.HCD.Administrative.Entities.TableNames.KinshipTable].Copy(); * ds.Tables.Add(dt); * } #endregion * #region Person * if (personID <= 0) * { * throw new Exception(Properties.Resources.ERROR_NOKPersonNotFound); * } * SII.HCD.BackOffice.Entities.PersonEntity myPerson = personBL.GetPerson(personID); #endregion * * NOKEntity result = nokAdapter.GetInfo(ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows[0], ds); * result.Person = myPerson; * LOPDLogger.Write(EntityNames.NOKEntityName, nokID, ActionType.View); * return result; * } * else * return null; * } * catch (Exception ex) * { * if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service)) throw; * return null; * } * } */ public NOKEntity GetNOK(int nokID) { try { #region Person PersonBL personBL = new PersonBL(); int personID = 0; personID = personBL.obtenerPersonID_From_NOK(nokID); if (personID == 0) { throw new Exception(Properties.Resources.ERROR_NOKPersonNotFound); } PersonEntity myPerson = null; var HiloPerson = System.Threading.Tasks.Task.Factory.StartNew(() => myPerson = personBL.GetPerson(personID)); #endregion DataSet ds = _nokDA.GetNOK(nokID); if ((ds.Tables != null) && (ds.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.NOKTable)) && (ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows.Count > 0)) { DataSet ds2 = new DataSet(); foreach (DataTable oTabla in ds.Tables) { if (oTabla.Rows.Count > 0) { ds2.Tables.Add(oTabla.Copy()); } } NOKAdapter nokAdapter = new NOKAdapter(); NOKEntity result = nokAdapter.GetInfo(ds.Tables[SII.HCD.Administrative.Entities.TableNames.NOKTable].Rows[0], ds2); HiloPerson.Wait(); result.Person = myPerson; LOPDLogger.Write(EntityNames.NOKEntityName, nokID, ActionType.View); ds.Dispose(); ds2.Dispose(); return(result); } else { return(null); } } catch (Exception ex) { if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service)) { throw; } return(null); } }
/* * public CustomerContactPersonEntity GetCustomerContactPerson(int customerContactPersonID) * { * try * { * PersonBL personBL = new PersonBL(); * * DataSet ds = _customerContactPersonDA.GetCustomerContactPerson(customerContactPersonID); * if ((ds.Tables != null) && (ds.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.CustomerContactPersonTable)) && (ds.Tables[SII.HCD.Administrative.Entities.TableNames.CustomerContactPersonTable].Rows.Count > 0)) * { * int personID = SIIConvert.ToInteger(ds.Tables[SII.HCD.Administrative.Entities.TableNames.CustomerContactPersonTable].Rows[0]["PersonID"].ToString(), 0); * int contactTypeID = SIIConvert.ToInteger(ds.Tables[SII.HCD.Administrative.Entities.TableNames.CustomerContactPersonTable].Rows[0]["ContactTypeID"].ToString(), 0); * * DataSet ds2; * #region Contact Types * ds2 = _contactTypeDA.GetContactTypeByID(contactTypeID); * if ((ds2 != null) && (ds2.Tables.Contains(SII.HCD.Administrative.Entities.TableNames.ContactTypeTable))) * { * DataTable dt = ds2.Tables[SII.HCD.Administrative.Entities.TableNames.ContactTypeTable].Copy(); * ds.Tables.Add(dt); * } #endregion * #region Person * if (personID <= 0) * { * throw new Exception(Properties.Resources.ERROR_CustomerContactPersonNotFound); * } * SII.HCD.BackOffice.Entities.PersonEntity myPerson = personBL.GetPerson(personID); #endregion * * CustomerContactPersonAdvancedAdapter customerContactPersonAdapter = new CustomerContactPersonAdvancedAdapter(); * CustomerContactPersonEntity result = customerContactPersonAdapter.GetInfo(ds.Tables[SII.HCD.Administrative.Entities.TableNames.CustomerContactPersonTable].Rows[0], ds); * result.Person = myPerson; * LOPDLogger.Write(EntityNames.CustomerContactPersonEntityName, customerContactPersonID, ActionType.View); * return result; * } * else * return null; * } * catch (Exception ex) * { * if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service)) throw; * return null; * } * } */ public CustomerContactPersonEntity GetCustomerContactPerson(int customerContactPersonID) { try { #region Person PersonBL personBL = new PersonBL(); int personID = 0; personID = personBL.obtenerPersonID_From_CustomerContactPerson(customerContactPersonID); if (personID == 0) { throw new Exception(Properties.Resources.ERROR_CustomerContactPersonNotFound); } PersonEntity myPerson = null; var HiloPerson = System.Threading.Tasks.Task.Factory.StartNew(() => myPerson = personBL.GetPerson(personID)); #endregion DataSet ds = _customerContactPersonDA.GetCustomerContactPerson(customerContactPersonID); if ((ds.Tables != null) && (ds.Tables.Contains(Entities.TableNames.CustomerContactPersonTable)) && (ds.Tables[Entities.TableNames.CustomerContactPersonTable].Rows.Count > 0)) { DataSet ds2 = new DataSet(); foreach (DataTable oTabla in ds.Tables) { if (oTabla.Rows.Count > 0) { ds2.Tables.Add(oTabla.Copy()); } } CustomerContactPersonAdvancedAdapter customerContactPersonAdapter = new CustomerContactPersonAdvancedAdapter(); CustomerContactPersonEntity result = customerContactPersonAdapter.GetInfo(ds.Tables[Entities.TableNames.CustomerContactPersonTable].Rows[0], ds2); HiloPerson.Wait(); result.Person = myPerson; LOPDLogger.Write(EntityNames.CustomerContactPersonEntityName, customerContactPersonID, ActionType.View); ds2.Dispose(); ds.Dispose(); return(result); } else { return(null); } } catch (Exception ex) { if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service)) { throw; } return(null); } }