public void AddContact(Customers firm, Customers agent) { if (!db.Contacts.Any(c => c.firmID == firm.customerID && c.agentID == agent.customerID)) { Contacts newContact = new Contacts() { agentID = agent.customerID, firmID = firm.customerID }; db.Contacts.Add(newContact); db.SaveChanges(); } }
public static CustomerBaseRepresentation convertCustomer(Customers customer) { if (customer == null) return null; CustomerBaseRepresentation convertedCustomer; if (customer.isFirm) convertedCustomer = new FirmRepresentation(); else convertedCustomer = new PersonRepresentation(); // TODO: Implement concurency checking (rowVersion) convertedCustomer.id = customer.customerID; convertedCustomer.comment = customer.comment; convertedCustomer.customerAddress = customer.customerAddress; convertedCustomer.customerName = customer.customerName; convertedCustomer.customerPhone = customer.customerPhone; convertedCustomer.defaultDiscount = customer.defaultDiscount == null ? 0 : (customer.defaultDiscount ?? 0) / 100; convertedCustomer.IDNumber = customer.IDNumber; convertedCustomer.isDeleted = customer.isDeleted; convertedCustomer.isFirm = customer.isFirm; convertedCustomer.problems = customer.problems; convertedCustomer.rentCounter = customer.rentCounter; convertedCustomer.serviceCounter = customer.serviceCounter; if (customer.isFirm) { ((FirmRepresentation)convertedCustomer).contacts = new ObservableCollection<CustomerBaseRepresentation>(); if (customer.Contacts != null) { foreach (Contacts contact in customer.Contacts) { ((FirmRepresentation)convertedCustomer).contacts.Add(DataProxy.Instance.GetCustomerById(contact.agentID)); } } } else { ((PersonRepresentation)convertedCustomer).birthDate = customer.birthDate; ((PersonRepresentation)convertedCustomer).mothersName = customer.mothersName; ((PersonRepresentation)convertedCustomer).workplace = customer.workPlace; } if (customer.Cities != null) { convertedCustomer.city = convertCity(customer.Cities); } return convertedCustomer; }
public TestDatabase() { Cities city01 = new Cities() { cityID = 1, city = "Dunaújváros", isDeleted = false, postalCode = "2400" }; testCities.Add(city01); Cities city02 = new Cities() { cityID = 2, city = "Győr", isDeleted = false, postalCode = "1234" }; testCities.Add(city02); Cities city03 = new Cities() { cityID = 3, city = "Balassagyarmat", isDeleted = false, postalCode = "5847" }; testCities.Add(city03); Customers person01 = new Customers() { customerID = 1, birthDate = new DateTime(1980, 3, 2), cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "Teszt Béla Károly", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isDeleted = false, isFirm = false, mothersName = "Kovács Laura", serviceCounter = 0, rentCounter = 0, workPlace = "ISD Dunaferr" }; testCustomers.Add(person01); Customers person02 = new Customers() { customerID = 2, birthDate = new DateTime(1980, 3, 2), cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "Gipsz Jakab", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isDeleted = false, isFirm = false, mothersName = "Kovács Laura", serviceCounter = 0, rentCounter = 0, workPlace = "ISD Dunaferr" }; testCustomers.Add(person02); Customers person03 = new Customers() { customerID = 3, birthDate = new DateTime(1980, 3, 2), cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "Halocsekerentyű Leokádia", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isDeleted = false, isFirm = false, mothersName = "Kovács Laura", serviceCounter = 0, rentCounter = 0, workPlace = "ISD Dunaferr" }; testCustomers.Add(person03); Customers person04 = new Customers() { customerID = 4, birthDate = new DateTime(1980, 3, 2), cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "Vaszlavics Ilona", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isDeleted = false, isFirm = false, mothersName = "Kovács Laura", serviceCounter = 0, rentCounter = 0, workPlace = "ISD Dunaferr" }; testCustomers.Add(person04); Customers person05 = new Customers() { customerID = 5, birthDate = new DateTime(1980, 3, 2), cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "Kotyogó Júlia", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isDeleted = false, isFirm = false, mothersName = "Kovács Laura", serviceCounter = 0, rentCounter = 0, workPlace = "ISD Dunaferr" }; testCustomers.Add(person05); Customers firm01 = new Customers() { customerID = 100, cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "Óvárosi Csavarbolt", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isDeleted = false, isFirm = true, serviceCounter = 0, rentCounter = 0 }; testCustomers.Add(firm01); Customers firm02 = new Customers() { customerID = 101, cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "ISD Dunaferr", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isDeleted = false, isFirm = true, serviceCounter = 0, rentCounter = 0 }; testCustomers.Add(firm02); Customers firm03 = new Customers() { customerID = 102, cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "Hankook", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isDeleted = false, isFirm = true, serviceCounter = 0, rentCounter = 0 }; testCustomers.Add(firm03); Contacts firm01contact01 = new Contacts() { contactID = 1, firmID = firm01.customerID, agentID = person02.customerID }; testContacts.Add(firm01contact01); Contacts firm02contact01 = new Contacts() { contactID = 2, firmID = firm02.customerID, agentID = person01.customerID }; testContacts.Add(firm02contact01); Contacts firm02contact02 = new Contacts() { contactID = 3, firmID = firm02.customerID, agentID = person04.customerID }; testContacts.Add(firm02contact02); testDetailedCustomers.Add(new DetailedCustomers() { customerID = 5, birthDate = new DateTime(1980, 3, 2), cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "Kotyogó Júlia", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isFirm = false, mothersName = "Kovács Laura", serviceCounter = 0, rentCounter = 0, workPlace = "ISD Dunaferr", city = "Dunaújváros", cityDeleted = false, customerDeleted = false, postalCode = "2400" }); testDetailedCustomers.Add(new DetailedCustomers() { customerID = 102, cityID = city01.cityID, customerAddress = "Almafa utca 32.", customerName = "Hankook", customerPhone = "+36/30/517-6289", IDNumber = "JD245874", isFirm = true, serviceCounter = 0, rentCounter = 0, city = "Dunaújváros", cityDeleted = false, customerDeleted = false, postalCode = "2400" }); }
public Contacts GetContactByFirmAndAgent(Customers firm, Customers agent) { return db.Contacts.SingleOrDefault(c => c.firmID == firm.customerID && c.agentID == agent.customerID); }
public void DeleteContact(Customers firm, Customers agent) { Contacts contactForDelete = db.Contacts.SingleOrDefault(c => c.firmID == firm.customerID && c.agentID == agent.customerID); if (contactForDelete != null) { db.Contacts.Remove(contactForDelete); db.SaveChanges(); } }
public Contacts GetContactByFirmAndAgent(Customers firm, Customers agent) { return(testContacts.SingleOrDefault(c => c.firmID == firm.customerID && c.agentID == agent.customerID)); }
public void UpdateCustomer(Customers customer) { testCustomers[testCustomers.FindIndex(c => c.customerID == customer.customerID)] = customer; }
public static Customers convertCustomer(CustomerBaseRepresentation customer) { // TODO: Implement concurency checking (rowVersion) var convertedCustomer = new Customers() { customerID = customer.id, comment = customer.comment, customerAddress = customer.customerAddress, customerName = customer.customerName, customerPhone = customer.customerPhone, defaultDiscount = customer.defaultDiscount * 100, IDNumber = customer.IDNumber, isDeleted = customer.isDeleted, isFirm = customer.isFirm, problems = customer.problems, rentCounter = customer.rentCounter, serviceCounter = customer.serviceCounter }; if (customer.GetType() == typeof(PersonRepresentation)) { convertedCustomer.birthDate = ((PersonRepresentation)customer).birthDate; convertedCustomer.mothersName = ((PersonRepresentation)customer).mothersName; convertedCustomer.workPlace = ((PersonRepresentation)customer).workplace; } if (customer.city != null) { convertedCustomer.cityID = customer.city.id; } return convertedCustomer; }
public void DeleteContact(Customers firm, Customers agent) { Contacts contactToDelete = GetContactByFirmAndAgent(firm, agent); if (contactToDelete != null) { testContacts.Remove(contactToDelete); } }
public long AddCustomer(Customers customer) { testCustomers.Add(customer); return customer.customerID; }
public void AddContact(Customers firm, Customers agent) { long maxID = testContacts.Max(c => c.contactID); testContacts.Add(new Contacts() { contactID = maxID + 1, firmID = firm.customerID, agentID = agent.customerID }); }
public List<Customers> GetContacts(Customers firm) { List<long> agentIDList = testContacts.Where(c => c.firmID == firm.customerID).Select(co => co.agentID).ToList(); return testCustomers.Where(c => agentIDList.Contains(c.customerID)).ToList(); }
void acceptGroupExecute() { Customers c = new Customers(); ServiceGroups sg = new ServiceGroups(); long cIDTemp; cIDTemp = newWorksheets[0].customerID; //c = SQLConnection.Execute.CustomersTable.Single(cust => cust.customerID == cIDTemp); c.serviceCounter += 1; sg.deposit = deposit; //SQLConnection.Execute.ServiceGroupsTable.AddObject(sg); //db.SaveChanges(); foreach (ServiceWorksheets item in newWorksheets) { item.groupID = sg.serviceGroupID; //SQLConnection.Execute.ServiceWorksheetsTable.AddObject(item); } SQLConnection.Execute.SaveDb(); foreach (ServiceWorksheets item in newWorksheets) { new Print.printService(item, Print.servicePrintType.bringIn); } AppMessages.ServiceGroupClosed.Send(newWorksheets); }
public List<Customers> GetContacts(Customers firm) { return db.Customers.Where(c => c.Contacts1.Any(ca => ca.firmID == firm.customerID)).ToList(); }
public void UpdateCustomer(Customers customer) { Customers customerToUpdate = db.Customers.SingleOrDefault(c => c.customerID == customer.customerID); // TODO: Implement //if (customerToUpdate.rowVersion != customer.rowVersion) //{ // throw new Exception("Customer modification conflicted"); //} customerToUpdate.birthDate = customer.birthDate; customerToUpdate.cityID = customer.cityID; customerToUpdate.comment = customer.comment; customerToUpdate.customerAddress = customer.customerAddress; customerToUpdate.customerName = customer.customerName; customerToUpdate.customerPhone = customer.customerPhone; customerToUpdate.defaultDiscount = customer.defaultDiscount; customerToUpdate.IDNumber = customer.IDNumber; customerToUpdate.isDeleted = customer.isDeleted; customerToUpdate.isFirm = customer.isFirm; customerToUpdate.mothersName = customer.mothersName; customerToUpdate.problems = customer.problems; customerToUpdate.rentCounter = customer.rentCounter; customerToUpdate.serviceCounter = customer.serviceCounter; customerToUpdate.workPlace = customer.workPlace; db.SaveChanges(); }
public long AddCustomer(Customers customer) { testCustomers.Add(customer); return(customer.customerID); }
public long AddCustomer(Customers customer) { db.Customers.Add(customer); db.SaveChanges(); return customer.customerID; }
public List <Customers> GetContacts(Customers firm) { List <long> agentIDList = testContacts.Where(c => c.firmID == firm.customerID).Select(co => co.agentID).ToList(); return(testCustomers.Where(c => agentIDList.Contains(c.customerID)).ToList()); }