internal static PersonDto GetByLogin(Rbr_Db pDb, string pLogin) { PersonRow _personRow = pDb.PersonCollection.GetByLogin(pLogin); if (_personRow == null) { return(null); } ContactInfoDto _contactInfo = null; CustomerSupportGroupDto _customerSupportGroup = null; VirtualSwitchDto _virtualSwitch = null; if (!_personRow.IsContact_info_idNull) { _contactInfo = ContactInfoManager.Get(pDb, _personRow.Contact_info_id); } if (!_personRow.IsGroup_idNull) { _customerSupportGroup = CustomerSupportManager.GetCustomerSupportGroup(pDb, _personRow.Group_id); } if (!_personRow.IsVirtual_switch_idNull) { _virtualSwitch = VirtualSwitchManager.Get(pDb, _personRow.Virtual_switch_id); } return(mapToPerson(_personRow, _contactInfo, _customerSupportGroup, _virtualSwitch)); }
public static void SaveCustomerSupportGroup(CustomerSupportGroupDto pCustomerSupportGroup) { using (Rbr_Db _db = new Rbr_Db()) { using (Transaction _tx = new Transaction(_db, pCustomerSupportGroup)) { CustomerSupportManager.SaveCustomerSupportGroup(_db, pCustomerSupportGroup); _tx.Commit(); } } }
static internal CustomerSupportGroupDto mapToCustomerSupportGroup(CustomerSupportGroupRow pCustomerSupportGroupRow) { if (pCustomerSupportGroupRow == null) { return(null); } CustomerSupportGroupDto _customerSupportGroup = new CustomerSupportGroupDto(); _customerSupportGroup.GroupId = pCustomerSupportGroupRow.Group_id; _customerSupportGroup.Description = pCustomerSupportGroupRow.Description; _customerSupportGroup.GroupRole = pCustomerSupportGroupRow.GroupRole; _customerSupportGroup.MaxAmount = pCustomerSupportGroupRow.Max_amount; _customerSupportGroup.AllowStatusChange = pCustomerSupportGroupRow.AllowStatusChange; _customerSupportGroup.VendorId = pCustomerSupportGroupRow.Vendor_id; return(_customerSupportGroup); }
internal static PersonDto[] GetByGroupId(Rbr_Db pDb, int pGroupId) { var _list = new ArrayList(); CustomerSupportGroupDto _customerSupportGroup = CustomerSupportManager.GetCustomerSupportGroup(pDb, pGroupId); PersonRow[] _personRows = pDb.PersonCollection.GetByGroup_id(pGroupId); foreach (PersonRow _personRow in _personRows) { ContactInfoDto _contactInfo = null; if (!_personRow.IsContact_info_idNull) { _contactInfo = ContactInfoManager.Get(pDb, _personRow.Contact_info_id); } _list.Add(mapToPerson(_personRow, _contactInfo, _customerSupportGroup, null)); } if (_list.Count > 1) { _list.Sort(new GenericComparer(PersonDto.Name_PropName, ListSortDirection.Ascending)); } return((PersonDto[])_list.ToArray(typeof(PersonDto))); }
internal static void SaveCustomerSupportGroup(Rbr_Db pDb, CustomerSupportGroupDto pCustomerSupportGroup) { try { CustomerSupportGroupRow _customerSupportGroupRow = mapToCustomerSupportGroupRow(pCustomerSupportGroup); if (_customerSupportGroupRow != null) { if (_customerSupportGroupRow.Group_id == 0) { pDb.CustomerSupportGroupCollection.Insert(_customerSupportGroupRow); pCustomerSupportGroup.GroupId = _customerSupportGroupRow.Group_id; } else { pDb.CustomerSupportGroupCollection.Update(_customerSupportGroupRow); } } } catch (AlternateKeyException) { throw new LoginNameAlreadyInUseException(); } }
static PersonDto mapToPerson(PersonRow pPersonRow, ContactInfoDto pContactInfo, CustomerSupportGroupDto pCustomerSupportGroup, VirtualSwitchDto pVirtualSwitch) { if (pPersonRow == null) { return(null); } var _person = new PersonDto(); _person.PersonId = pPersonRow.Person_id; _person.Name = pPersonRow.Name; _person.Login = pPersonRow.Login; _person.Password = pPersonRow.Password; _person.AccessScope = pPersonRow.AccessScope; _person.PermissionType = pPersonRow.PermissionType; _person.RegistrationStatus = pPersonRow.RegistrationStatus; _person.Status = pPersonRow.PersonStatus; _person.Salt = pPersonRow.Salt; if (!pPersonRow.IsPartner_idNull) { _person.PartnerId = pPersonRow.Partner_id; } if (!pPersonRow.IsRetail_acct_idNull) { _person.RetailAcctId = pPersonRow.Retail_acct_id; } if (pCustomerSupportGroup != null) { _person.CustomerSupportGroup = pCustomerSupportGroup; } if (pVirtualSwitch != null) { _person.VirtualSwitch = pVirtualSwitch; } if (pContactInfo != null) { _person.ContactInfo = pContactInfo; } return(_person); }