public static bool DeleteCustomers(string connectionString, IEnumerable <Customer> customers) { try { using (var context = new CustomerDBContext(connectionString)) { foreach (var customer in customers.Select(customer => new Customer() { ID = customer.ID })) { context.Customers.Attach(customer); context.Customers.Remove(customer); } var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static bool AddCustomerHearingAidOrder(string connectionString, CustomerHearingAidOrder customerHearingAidOrder) { try { using (var context = new CustomerDBContext(connectionString)) { //_connectionString = connectionString; var cloneObject = customerHearingAidOrder.CreateAClone <CustomerHearingAidOrder>(); context.CustomerHearingAidOrders.Add(cloneObject); var result = context.SaveChanges(); #region Adding Reminder var reminder = new Reminder() { ReminderName = "Warrenty Reminder for 1st Year " + customerHearingAidOrder.Customer.FormattedName, ReminderDate = customerHearingAidOrder.OrderDate.AddMonths(11), ReminderType = ReminderType.Information, ReminderMessage = "Warrenty Reminder for 1st Year " + Environment.NewLine + customerHearingAidOrder.Customer.FormattedName + Environment.NewLine + "Order Date " + customerHearingAidOrder.OrderDate }; ReminderAction.AddReminder(connectionString, reminder); var reminderConti = new Reminder() { ReminderName = "Warrenty Reminder for 2nd Year " + customerHearingAidOrder.Customer.FormattedName, ReminderDate = customerHearingAidOrder.OrderDate.AddMonths(23), ReminderType = ReminderType.Information, ReminderMessage = "Warrenty Reminder for 2nd Year " + Environment.NewLine + customerHearingAidOrder.Customer.FormattedName + Environment.NewLine + "Order Date " + customerHearingAidOrder.OrderDate }; ReminderAction.AddReminder(connectionString, reminderConti); #endregion return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static bool DeleteCustomerAddresses(string connectionString, IEnumerable <CustomerAddress> customerAddresses) { try { using (var context = new CustomerDBContext(connectionString)) { foreach (var customerAddress in customerAddresses.Select(customerAddress => new CustomerAddress() { ID = customerAddress.ID })) { context.Entry(customerAddress).State = EntityState.Deleted; } var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static bool AddCustomerEarMoldOrder(string connectionString, CustomerEarMoldOrder customerEarMoldOrder) { try { using (var context = new CustomerDBContext(connectionString)) { var cloneObject = customerEarMoldOrder.CreateAClone <CustomerEarMoldOrder>(); context.CustomerEarMoldOrders.Add(cloneObject); var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static bool AddCustomerWarrantyInformed(string connectionString, CustomerWarrantyInformed customerWarrantyInformed) { try { using (var context = new CustomerDBContext(connectionString)) { var cloneObject = customerWarrantyInformed.CreateAClone(); cloneObject.ApplyCurrentDateTime(); context.CustomerWarrantyInformeds.Add(cloneObject); var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } return(false); }