public void GroupAdd() { Group group = new Group(); string name1 = "maichao"; string company1 = "ynu"; string position1 = "student"; Person person1 = new Person { Name = name1, Company = company1, Position = position1 }; group.AddPerson(person1); Assert.AreEqual(1, group.Amount); string name2 = "mai"; string company2 = "ynu"; string position2 = "graduate"; Person person2 = new Person { Name = name2, Company = company2, Position = position2 }; group.AddPerson(person2); Assert.AreEqual(2, group.Amount); Assert.AreNotEqual(group.Persons[0], group.Persons[1]); }
public GroupWindow(ref Services services, ref Group group, EditMode mode) { InitializeComponent(); this.services = services; this.group = group; this.mode = mode; InitializeUI(); }
public ModifyGroupWindow(ref Services services, ref Group curGroup, ref Person person, ModifyGroupMode mode) { InitializeComponent(); this.services = services; this.curGroup = curGroup; this.person = person; this.mode = mode; InitializeUI(); }
public void DeleteGroup(Group group) { Group groupDefault = this.SearchGroup("Default")[0]; // move its contacts to default group foreach (Person person in group.Persons) { groupDefault.AddPerson(person); } // delete it groups.Remove(this.SearchGroupById(group.Id)); }
public void GeatherData(ref Group group) { foreach (var item in grid.Children) { if (item is TextBox) { TextBox textBox = item as TextBox; object tag = textBox.Tag; PropertyInfo tagProperty = tag as PropertyInfo; Type t = typeof(Group); var properties = t.GetProperties(); foreach (PropertyInfo property in properties) { if (tagProperty != null && tagProperty.Name == property.Name) { if (property.PropertyType.ToString() == "System.String") { property.SetValue(group, textBox.Text); } else if (property.PropertyType.ToString() == "System.Int32") { // dont't need to set amount } else { if (!property.PropertyType.IsGenericType) { var instance = Activator.CreateInstance(property.PropertyType, textBox.Text); property.SetValue(group, instance); } // don't have to handle persons, user will maintain it. } } } } } }
public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var group = new Domain.Group { Id = request.Id, navn = request.navn, beskrivelse = request.beskrivelse, aktiv = request.aktiv, aktiv_til_og_med = request.aktiv_til_og_med, opprettet = request.opprettet, groupType = request.groupType, OrganisationId = request.organisation }; _context.Groups.Add(group); var user = await _context.Users.SingleOrDefaultAsync(x => x.UserName == _userAccessor.GetCurrentUsername()); var admin = new UserGroup { AppUser = user, Group = group, GroupAdmin = true, DateJoined = DateTime.Now }; _context.UserGroups.Add(admin); var success = await _context.SaveChangesAsync() > 0; if (success) { return(Unit.Value); } throw new Exception("Problem saving changes"); }
public List<Group> SearchPerson(string condition) { List<Group> resGroup = new List<Group>(); foreach (var group in groups) { Group g = new Group() { Name = group.Name }; var persons = group.Persons; foreach (var person in persons) { Type t = typeof(Person); var properties = t.GetProperties(); foreach (var property in properties) { object value = property.GetValue(person); if (value != null && value.ToString() == condition) { if (!resGroup.Contains(g)) { resGroup.Add(g); } if (!g.Persons.Contains(person)) { g.AddPerson(person); } } } } } return resGroup; }
public void GroupSearchPerson() { Group group = new Group(); string name1 = "maichao"; string company1 = "ynu"; string position1 = "student"; Person person1 = new Person { Name = name1, Company = company1, Position = position1 }; group.AddPerson(person1); string name2 = "mai"; string company2 = "ynu"; string position2 = "graduate"; Person person2 = new Person { Name = name2, Company = company2, Position = position2 }; group.AddPerson(person2); string name3 = "chao"; string company3 = "ynu"; string position3 = "ynu"; Person person3 = new Person { Name = name3, Company = company3, Position = position3 }; group.AddPerson(person3); var ans1 = group.SearchPerson("mai"); Assert.IsNotNull(ans1); Assert.AreEqual(1, ans1.Count); var ans2 = group.SearchPerson("ynu"); Assert.IsNotNull(ans2); Assert.AreEqual(3, ans2.Count); }
public void GroupGetPersons() { Group group = new Group(); string name1 = "maichao"; string company1 = "ynu"; string position1 = "student"; Person person1 = new Person { Name = name1, Company = company1, Position = position1 }; group.AddPerson(person1); string name2 = "mai"; string company2 = "ynu"; string position2 = "graduate"; Person person2 = new Person { Name = name2, Company = company2, Position = position2 }; group.AddPerson(person2); List<Person> persons = group.Persons; Assert.IsNotNull(persons); Assert.AreEqual(2, group.Amount); }
public void ContactsAdd() { Contacts contacts = new Contacts(); Group group1 = new Group(); string name1 = "maichao"; string company1 = "ynu"; string position1 = "student"; Person person1 = new Person { Name = name1, Company = company1, Position = position1 }; group1.AddPerson(person1); Assert.AreEqual(1, group1.Amount); string name2 = "mai"; string company2 = "ynu"; string position2 = "graduate"; Person person2 = new Person { Name = name2, Company = company2, Position = position2 }; group1.AddPerson(person2); Group group2 = new Group(); string name3 = "chao"; string company3 = "ynu"; string position3 = "graduate"; Person person3 = new Person { Name = name3, Company = company3, Position = position3 }; group2.AddPerson(person3); Group group3 = new Group(); string name4 = "maichao"; string company4 = "ynu"; string position4 = "student"; Person person4 = new Person { Name = name4, Company = company4, Position = position4 }; group3.AddPerson(person4); Assert.AreEqual(1, group3.Amount); string name5 = "mai"; string company5 = "ynu"; string position5 = "graduate"; Person person5 = new Person { Name = name5, Company = company5, Position = position5 }; group3.AddPerson(person5); contacts.AddGroup(group1); contacts.AddGroup(group2); contacts.AddGroup(group3); Assert.AreEqual(4, contacts.GroupsAmount); Assert.AreEqual(5, contacts.PersonsAmount); }
public void AddPersonToGroup(Person person, Group group) { this.SearchGroupById(group.Id).AddPerson(person); }
public void AddGroup(Group group) { groups.Add(group); }
public Contacts() { groups = new List<Group>(); Group group = new Group() { Name = "Default" }; this.AddGroup(group); }
public void UpdateGroup(Group group) { this.SearchGroupById(group.Id).UpdateInfo(group); }
private void MenuItem_Click_GroupsNew(object sender, RoutedEventArgs e) { Group newGroup = new Group(); GroupWindow groupWindow = new GroupWindow(ref services, ref newGroup, EditMode.New); groupWindow.ShowDialog(); LoadData(services.GetGroups()); }
public void ContactsSearchGroup() { Contacts contacts = new Contacts(); string name1 ="family"; string name2 ="work"; string name3 ="other"; Group group1 = new Group() { Name = name1 }; Group group2 = new Group() { Name = name2 }; Group group3 = new Group() { Name = name3 }; contacts.AddGroup(group1); contacts.AddGroup(group2); contacts.AddGroup(group3); var res = contacts.SearchGroup("work"); Assert.AreEqual(1, res.Count); }
public void MovePersonToGroup(Person person, Group curGroup, Group newGroup) { contacts.MovePersonToGroup(person, curGroup, newGroup); }
public void SaveData() { //Contacts1 contacts1 = new Contacts1() { Name = "waef" }; //FileStream fileStream = new FileStream("data.dat", FileMode.Create, FileAccess.Write); //BinaryFormatter binaryFormatter = new BinaryFormatter(); //binaryFormatter.Serialize(fileStream, contacts1); Contacts contacts = new Contacts(); Group group1 = new Group(); string name1 = "maichao"; string company1 = "ynu"; string position1 = "student"; Person person1 = new Person { Name = name1, Company = company1, Position = position1 }; group1.AddPerson(person1); Assert.AreEqual(1, group1.Amount); string name2 = "mai"; string company2 = "ynu"; string position2 = "graduate"; Person person2 = new Person { Name = name2, Company = company2, Position = position2 }; group1.AddPerson(person2); Group group2 = new Group(); string name3 = "chao"; string company3 = "ynu"; string position3 = "graduate"; Person person3 = new Person { Name = name3, Company = company3, Position = position3 }; group2.AddPerson(person3); Group group3 = new Group(); string name4 = "maichao"; string company4 = "ynu"; string position4 = "student"; Person person4 = new Person { Name = name4, Company = company4, Position = position4 }; group3.AddPerson(person4); Assert.AreEqual(1, group3.Amount); string name5 = "mai"; string company5 = "ynu"; string position5 = "graduate"; Person person5 = new Person { Name = name5, Company = company5, Position = position5 }; group3.AddPerson(person5); string name = "maimai"; string company = "ynu"; string position = "graduate"; Person person = new Person { Name = name, Company = company, Position = position }; group1.AddPerson(person); group2.AddPerson(person); group3.AddPerson(person); contacts.AddGroup(group1); contacts.AddGroup(group2); contacts.AddGroup(group3); FileStream fileStream = new FileStream("data.dat", FileMode.Create, FileAccess.Write); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(fileStream, person1); //BinaryDataAccess bda = new BinaryDataAccess(); //bda.SaveData(contacts, "data.dat"); }
public void UpdateGroup(Group group) { contacts.UpdateGroup(group); }
public void AddGroup(Group group) { contacts.AddGroup(group); }
public void AddPersonToGroup(Person person, Group group) { contacts.AddPersonToGroup(person, group); }
public void GroupNew() { string name = "family"; Group group = new Group(); Assert.IsNotNull(group.Id); Assert.AreEqual(0, group.Amount); group.Name = name; Assert.AreEqual(name, group.Name); }
public void DeleteGroup(Group group) { contacts.DeleteGroup(group); }
public void GroupSearchPersonById() { Group group = new Group(); string name1 = "maichao"; string company1 = "ynu"; string position1 = "student"; Person person1 = new Person { Name = name1, Company = company1, Position = position1 }; group.AddPerson(person1); string name2 = "mai"; string company2 = "ynu"; string position2 = "graduate"; Person person2 = new Person { Name = name2, Company = company2, Position = position2 }; group.AddPerson(person2); Person person = group.SearchPersonById(person1.Id); Assert.IsNotNull(person); Assert.AreEqual(person1.Id, person.Id); Assert.AreEqual(name1, person.Name); Assert.AreEqual(company1, person.Company); Assert.AreEqual(position1, person.Position); }
public void LoadContacts() { //BinaryDataAccess bda = new BinaryDataAccess(); //this.contacts = bda.LoadData("data.dat"); Group group1 = new Group(); group1.Name = "Family"; string name1 = "maichao"; string company1 = "ynu"; string position1 = "student"; Person person1 = new Person { Name = name1, Company = company1, Position = position1 }; Pair<string, string> num1 = new Pair<string, string>("187", "cellphone"); Pair<Guid, Pair<string, string>> phone1 = new Pair<Guid, Pair<string, string>>(Guid.NewGuid(), num1); person1.AddPhone(phone1); Pair<string, string> num2 = new Pair<string, string>("187", "cellphone"); Pair<Guid, Pair<string, string>> phone2 = new Pair<Guid, Pair<string, string>>(Guid.NewGuid(), num2); person1.AddPhone(phone2); group1.AddPerson(person1); string name2 = "mai"; string company2 = "ynu"; string position2 = "graduate"; Person person2 = new Person { Name = name2, Company = company2, Position = position2 }; group1.AddPerson(person2); Group group2 = new Group(); group2.Name = "Work"; string name3 = "chao"; string company3 = "ynu"; string position3 = "graduate"; Person person3 = new Person { Name = name3, Company = company3, Position = position3 }; group2.AddPerson(person3); Group group3 = new Group(); group3.Name = "Other"; string name4 = "maichao"; string company4 = "ynu"; string position4 = "student"; Person person4 = new Person { Name = name4, Company = company4, Position = position4 }; group3.AddPerson(person4); string name5 = "mai"; string company5 = "ynu"; string position5 = "graduate"; Person person5 = new Person { Name = name5, Company = company5, Position = position5 }; group3.AddPerson(person5); string name = "maimai"; string company = "ynu"; string position = "graduate"; Person person = new Person { Name = name, Company = company, Position = position }; group1.AddPerson(person); group2.AddPerson(person); group3.AddPerson(person); contacts.AddGroup(group1); contacts.AddGroup(group2); contacts.AddGroup(group3); }
public void UpdateInfo(Group group) { this.Name = group.Name; }
public void MovePersonToGroup(Person person, Group curGroup, Group newGroup) { this.SearchGroupById(newGroup.Id).AddPerson(person); this.SearchGroupById(curGroup.Id).DeletePerson(person); }