public List <AccountPerson> GetEmployeeListByAccount(Account account) { if (account == null) { throw new ArgumentNullException(nameof(account)); } return(ExecuteFaultHandledOperation(() => { var employees = new List <AccountPerson>(); var acct = new AccountData() { AccountKey = account.AccountKey }; var emps_data = _entity_person_repo.GetAll(acct); foreach (EntityPersonData emp_data in emps_data) { Log.Debug("EntityPersonKey {0}", emp_data.EntityPersonKey); AccountPerson employee = _acct_es.Map(emp_data); //employee.PersonAttributes = entity_attrib_be.GetAttributeByEntity(employee.PersonKey, QIQOEntityType.Person); //employee.Addresses = address_be.GetAddressesByEntityID(employee.PersonKey, QIQOEntityType.Person); PersonData ent_per = _person_repo.GetByID(employee.PersonKey); _pers_es.InitPersonData(employee, ent_per); Log.Info($"Employee: {employee.PersonLastName}; Role: {employee.RoleInCompany}; Type: {employee.CompanyRoleType}; EntityPersonKey {employee.EntityPersonKey}"); employees.Add(employee); } return employees; })); }
public bool EmployeeDelete(Account account, AccountPerson employee) { if (account == null) { throw new ArgumentNullException(nameof(account)); } if (employee == null) { throw new ArgumentNullException(nameof(employee)); } return(ExecuteFaultHandledOperation(() => { var person = _pers_es.Map(employee); person.PersonKey = employee.PersonKey; EntityPersonData ep_data = new EntityPersonData() { EntityKey = account.AccountKey, EntityTypeKey = 3, // Account PersonKey = employee.PersonKey, PersonTypeKey = employee.PersonTypeData.PersonTypeKey, EntityPersonSeq = 1 // default; not used }; _entity_person_repo.DeleteByObject(ep_data); _person_repo.Delete(person); return true; })); }
public void PersonModelTest1() { var data = new PersonData { PersonKey = 1, PersonCode = "TEST", PersonFirstName = "TEST", PersonMi = "TEST", PersonLastName = "TEST", ParentPersonKey = 1, PersonDob = new System.DateTime(2018, 1, 1), AuditAddUserId = "TEST", AuditAddDatetime = new System.DateTime(2018, 1, 1), AuditUpdateUserId = "TEST", AuditUpdateDatetime = new System.DateTime(2018, 1, 1), }; var sut = new AccountPerson(data); Assert.True(sut.PersonKey == 1); Assert.True(sut.PersonCode == "TEST"); Assert.True(sut.PersonFirstName == "TEST"); Assert.True(sut.PersonMi == "TEST"); Assert.True(sut.PersonLastName == "TEST"); //Assert.True(sut.ParentPersonKey == 1); Assert.True(sut.PersonDob == new System.DateTime(2018, 1, 1)); }
private void EditEmployee() { if (EmpSelectedItem is AccountPersonWrapper emp_to_edit) { AccountPerson ap_copy = emp_to_edit.Model.Copy(); ChangeEmployee(ap_copy, ApplicationStrings.NotificationEdit); } }
public void AccountPersonUnitTests() { var now = DateTime.Now; var ap = new AccountPerson() { AddedDateTime = now, AddedUserID = "Test", Comment = "Test Comment", EndDate = DateTime.Today.AddYears(1), PersonCode = "TEST", PersonDOB = new DateTime(1966, 12, 3), PersonFirstName = "Test", PersonFullNameFL = "Test", PersonFullNameFML = "Test", PersonFullNameLF = "Test", PersonFullNameLFM = "Test", PersonKey = 100, PersonLastName = "Test", PersonMI = "T", RoleInCompany = "Test", StartDate = DateTime.Today, UpdateDateTime = now, UpdateUserID = "Test", EntityPersonKey = 162 }; Assert.NotNull(ap); Assert.NotNull(ap.Addresses); Assert.Empty(ap.Addresses); Assert.NotNull(ap.PersonAttributes); Assert.Empty(ap.PersonAttributes); Assert.NotNull(ap.PersonTypeData); Assert.Equal(0, ap.PersonTypeData.PersonTypeKey); Assert.Equal(QIQOPersonType.AccountEmployee, ap.CompanyRoleType); Assert.Equal(now, ap.AddedDateTime); Assert.Equal("Test", ap.AddedUserID); Assert.Equal("Test Comment", ap.Comment); Assert.Equal(DateTime.Today.AddYears(1), ap.EndDate); Assert.Equal("TEST", ap.PersonCode); Assert.Equal(new DateTime(1966, 12, 3), ap.PersonDOB); Assert.Equal("Test", ap.PersonFirstName); Assert.Equal("Test", ap.PersonFullNameFL); Assert.Equal("Test", ap.PersonFullNameFML); Assert.Equal("Test", ap.PersonFullNameLF); Assert.Equal("Test", ap.PersonFullNameLFM); Assert.Equal(100, ap.PersonKey); Assert.Equal("Test", ap.PersonLastName); Assert.Equal("T", ap.PersonMI); Assert.Equal("Test", ap.RoleInCompany); Assert.Equal(DateTime.Today, ap.StartDate); Assert.Equal(now, ap.UpdateDateTime); Assert.Equal("Test", ap.UpdateUserID); Assert.Equal(162, ap.EntityPersonKey); }
public PersonData Map(AccountPerson employee) { return(new PersonData() { PersonKey = employee.PersonKey, PersonFirstName = employee.PersonFirstName, PersonMi = employee.PersonMI, PersonLastName = employee.PersonLastName, PersonCode = employee.PersonCode, PersonDob = employee.PersonDOB }); }
public void InitPersonData(AccountPerson person, PersonData emp_data) { person.PersonKey = emp_data.PersonKey; person.PersonCode = emp_data.PersonCode; person.PersonFirstName = emp_data.PersonFirstName; person.PersonLastName = emp_data.PersonLastName; person.PersonDOB = emp_data.PersonDob; person.PersonMI = emp_data.PersonMi; person.PersonFullNameFL = emp_data.PersonFirstName + " " + emp_data.PersonLastName; person.PersonFullNameLF = emp_data.PersonLastName + ", " + emp_data.PersonFirstName; person.PersonFullNameLFM = emp_data.PersonLastName + ", " + emp_data.PersonFirstName + " " + emp_data.PersonMi; person.PersonFullNameFML = emp_data.PersonFirstName + " " + emp_data.PersonMi + " " + emp_data.PersonLastName; }
private void AddEmployee() { var emp_to_edit = new AccountPerson() { StartDate = DateTime.Today, EndDate = DateTime.Today.AddYears(5), Comment = "New account contact", CompanyRoleType = QIQOPersonType.AccountEmployee, RoleInCompany = "Account Contact" }; ChangeEmployee(emp_to_edit, ApplicationStrings.NotificationAdd); }
public AccountPersonViewModel Map(AccountPerson emp) { return(new AccountPersonViewModel() { RoleInCompany = emp.RoleInCompany, CompanyRoleType = emp.CompanyRoleType.ToString(), EntityPersonKey = emp.EntityPersonKey, StartDate = emp.StartDate, EndDate = emp.EndDate, Comment = emp.Comment, PersonKey = emp.PersonKey, PersonCode = emp.PersonCode, PersonFirstName = emp.PersonFirstName, PersonMI = emp.PersonMI, PersonLastName = emp.PersonLastName }); }
private void ChangeEmployee(AccountPerson employee, string action) { var emp_to_edit = employee as AccountPerson; if (emp_to_edit != null) { ItemEditNotification notification = new ItemEditNotification(emp_to_edit); notification.Title = action + " Account Employee"; //+ emp_to_edit.PersonCode + " - " + emp_to_edit.PersonFullNameFML; EditAccountPersonRequest.Raise(notification, r => { if (r != null && r.Confirmed && r.EditibleObject != null) // { AccountPerson emp = r.EditibleObject as AccountPerson; if (emp != null) { if (action == ApplicationStrings.NotificationEdit) { var emp_to_change = EmpSelectedItem as AccountPersonWrapper; if (emp_to_change != null) { emp_to_change.Comment = emp.Comment; emp_to_change.CompanyRoleType = emp.CompanyRoleType; emp_to_change.EndDate = emp.EndDate; emp_to_change.StartDate = emp.StartDate; emp_to_change.PersonCode = emp.PersonCode; emp_to_change.PersonDOB = emp.PersonDOB; emp_to_change.PersonFirstName = emp.PersonFirstName; emp_to_change.PersonLastName = emp.PersonLastName; emp_to_change.PersonMI = emp.PersonMI; emp_to_change.RoleInCompany = emp.RoleInCompany; } } else { Account.Employees.Add(new AccountPersonWrapper(emp)); } } } }); } }
public int EmployeeSave(Account account, AccountPerson employee, string role, string comment) { if (account == null) { throw new ArgumentNullException(nameof(account)); } if (employee == null) { throw new ArgumentNullException(nameof(employee)); } return(ExecuteFaultHandledOperation(() => { var person = _pers_es.Map(employee); person.PersonKey = employee.PersonKey; int person_key = _person_repo.Insert(person); //Log.Debug($"{person.PersonLastName} Employee Comment: {employee.Comment}"); EntityPersonData ep_data = new EntityPersonData() { EntityKey = account.AccountKey, EntityTypeKey = 3, PersonKey = person_key, PersonTypeKey = (int)QIQOPersonType.AccountContact, //employee.PersonTypeData.PersonTypeKey, PersonRole = employee.RoleInCompany, Comment = employee.Comment, StartDate = employee.StartDate, EndDate = employee.EndDate, EntityPersonKey = employee.EntityPersonKey }; int ep_ret = _entity_person_repo.Insert(ep_data); return person_key; })); }
public PersonData Map(AccountPerson ent) { throw new NotImplementedException(); }