private SharedDataTypes.Customer GaranteeCustomerExists(SharedDataTypes.Customer customer) { var tempMainCustomer = new DataBases.Customer(); var temp = mainDb.Customer.Where( x => x.FirstName.Equals(customer.FirstName) && x.LastName.Equals(customer.LastName) && x.Mail.Equals(customer.Mail) && x.PhoneNumber.Equals(customer.PhoneNumber) ).First(); //in case of new customer if (temp == null) { tempMainCustomer.ID_Customer = customer.CustomerId; tempMainCustomer.FirstName = customer.FirstName; tempMainCustomer.LastName = customer.LastName; tempMainCustomer.Mail = customer.Mail; tempMainCustomer.PhoneNumber = customer.PhoneNumber; mainDb.Customer.Add(tempMainCustomer); } else //in case of existing customers make sure the order has the right Guid { customer.CustomerId = temp.ID_Customer; } return(customer); }
//need to be passed public bool UpdateCustomer(SharedDataTypes.Customer c) { var temp = mainDb.Customer.Where(p => p.ID_Customer.Equals(c.CustomerId)).Select(p => p).First(); mainDb.Customer.Remove(temp); return(mainDb.SaveChanges() == 1); }
public Local_Database.Customer ConvertToDBCustomer(SharedDataTypes.Customer c) { return(new Local_Database.Customer { ID_Customer = c.CustomerId, FirstName = c.FirstName, LastName = c.LastName, Mail = c.Mail, PhoneNumber = c.PhoneNumber, ModifyDate = DateTime.Now }); }
public bool UpdateCustomer(SharedDataTypes.Customer c) { var temp = localDb.Customer.Where(p => p.ID_Customer.Equals(c.CustomerId)).Select(p => p).First(); temp.ID_Customer = c.CustomerId; temp.FirstName = c.FirstName; temp.LastName = c.LastName; temp.Mail = c.Mail; temp.PhoneNumber = c.PhoneNumber; temp.ModifyDate = DateTime.Now; return(localDb.SaveChanges() == 1); }
public bool InsertCustomer(SharedDataTypes.Customer c) { localDb.Customer.Add(converter.ConvertToDBCustomer(c)); return(localDb.SaveChanges() == 1); }