protected override void OnAction(ActionResult <UserLogin> result) { try { var userLoginActions = new UserLoginAction(); result.Data = userLoginActions.AuthenticateUserLogin(this.DBConnectionString, this.Entity); if (result.Data != null) { this.ParentViewModel.UpdateUserLogin(result.Data); result.Result = ActionResultType.DataFetched; this.CloseChild(); } else { StatusMessage = "Login Failed"; this.Entity.LoginPassword = string.Empty; result.Result = ActionResultType.DataNotFound; } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); } }
private void GetSearchList(string strSearchText) { try { if (string.IsNullOrEmpty(strSearchText)) { CustomerSearchList = null; IsPopupOpen = false; return; } Task.Factory.StartNew(() => { var customerActions = new CustomerAction(); CustomerSearchList = customerActions.GetCustomerSearchDictionary(this.DBConnectionString, strSearchText); IsPopupOpen = true; if (CustomerSearchList == null || !CustomerSearchList.Any()) { CustomerSearchList = new Dictionary <String, String>(); CustomerSearchList.Add(new KeyValuePair <string, string>("", "No records available")); } }); this.RaisePropertyChanged(() => CustomerSearchList); } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); } }
//private void CheckTimeOverLap(AppointmentCollection collection, Appointment appointment) //{ // try // { // collection.ObservableList.ForEach(x => x.IsAppointmentOverlapped = false); // appointment.IsAppointmentOverlapped = false; // var query = // collection.ObservableList.Where( // x => // x.EndTime > appointment.BeginTime && // x.BeginTime < appointment.EndTime); // var appointments = query as IList<Appointment> ?? query.ToList(); // if (appointments.Any(x => // { // if (!appointment.ID.HasValue) // return true; // return appointment.ID != x.ID; // })) // { // appointments.ForEach(x => x.IsAppointmentOverlapped = true); // appointment.IsAppointmentOverlapped = true; // } // } // catch (Exception exception) // { // NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, // ExceptionResources.ExceptionOccuredLogDetail); // } //} private void GetAppointmentsByDate(Appointment appointment, bool doAsync = false, bool findNextAppointment = false) { try { if (doAsync) { Task.Factory.StartNew(() => { this.AppointmentCollection = AppointmentAction.GetAppointments(this.DBConnectionString, appointment.AppointmentDate); this.ShowProgressBar = false; }); } else { this.AppointmentCollection = AppointmentAction.GetAppointments(this.DBConnectionString, appointment.AppointmentDate); this.ShowProgressBar = false; } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); } }
private void RefreshCustomerHearingAidOrderCollection(bool doAsync = false) { try { if (doAsync) { Task.Factory.StartNew(() => { var items = CustomerAction.GetCustomerHearingAidOrderList(this.DBConnectionString, this.Entity); if (items != null && items.InternalList.Any()) { this.Entity.CustomerHearingAidOrderCollection = items.InternalList; } }); } else { var items = CustomerAction.GetCustomerHearingAidOrderList(this.DBConnectionString, this.Entity); if (items != null && items.InternalList.Any()) { this.Entity.CustomerHearingAidOrderCollection = items.InternalList; } } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); } }
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 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 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 DeleteUserLogins(string connectionString, IEnumerable <UserLogin> userLogins) { try { using (var context = new UserLoginDBContext(connectionString)) { foreach (var userLogin in userLogins.Select(userLogin => new UserLogin() { ID = userLogin.ID })) { context.UserLogins.Attach(userLogin); context.UserLogins.Remove(userLogin); } var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
private void OnEditCustomer() { try { var childVM = new AddCustomerViewModel(this.Messenger, this.UserLogin, this.Entity.InternalList.FirstOrDefault(x => x.IsSelected)) { ParentViewModel = this }; childVM.RefreshCustomers += this.GetCustomerCollection; //childVM.SaveCustomer += // customer => CustomerAction.UpdateCustomer(this.DBConnectionString, // this.Entity.InternalList.FirstOrDefault(x => x.IsSelected)); var messageDailog = new VMMessageDailog() { ChildViewModel = childVM }; MessengerInstance.Send(messageDailog); } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); } }
public static CallRegistryCollection GetCallRegistries(string connectionString, string searchName, DateTime?callDate) { try { using (var context = new CallRegistryDBContext(connectionString)) { var callRegCollection = new CallRegistryCollection(); IQueryable <CallRegistry> items = null; if (callDate.HasValue && !string.IsNullOrEmpty(searchName)) { items = context.CallRegistries.Where( x => EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value) && x.Name.Contains(searchName)); } else if (!string.IsNullOrEmpty(searchName)) { items = context.CallRegistries.Where(x => x.Name.Contains(searchName)); } else if (callDate.HasValue) { items = context.CallRegistries.Where( x => EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value)); } else { items = context.CallRegistries; } if (items != null) { foreach (var callReg in items) { callRegCollection.Add(callReg); } } return(new CallRegistryCollection(callRegCollection.ObservableList.OrderByDescending(x => x.CallDate).ToList())); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
private void GetCustomerAppointments() { Task.Factory.StartNew(() => { try { this.Entity = AppointmentAction.GetAppointments(this.DBConnectionString, this.SelectedCustomer); } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); } }); }
public Dictionary <string, string> GetCustomerRepairSearchDictionary(string connectionString, string strSearchText) { try { using (var context = new CustomerDBContext(connectionString)) { return(null); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static bool UpdateCustomer(string connectionString, Customer customer) { try { _connectionString = connectionString; var entry = DBContextInstance.Entry(customer); entry.State = EntityState.Modified; var result = DBContextInstance.SaveChanges(); return(result > 0); } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static Customer GetCustomerByID(string connectionString, string customerId) { try { // var context = new CustomerDBContext(connectionString); _connectionString = connectionString; var id = Convert.ToInt32(customerId); return(DBContextInstance.Customers.FirstOrDefault(x => x.ID == id)); } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
//private void FindNextAvailableAppointmentTime() //{ // try // { // if (this.AppointmentCollection != null && // this.AppointmentCollection.InternalList.Any(x => x.BeginTime == this.Entity.BeginTime)) // { // this.Entity.BeginTime = this.Entity.BeginTime.AddMinutes(30); // FindNextAvailableAppointmentTime(); // } // } // catch (Exception exception) // { // NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, // ExceptionResources.ExceptionOccuredLogDetail); // } //} private void GetReminders(DateTime dateTime) { try { Task.Factory.StartNew(() => { this.ReminderList = ReminderAction.GetReminders(this.DBConnectionString, dateTime); }); } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); } }
public static ReminderCollection GetReminders(string connectionString) { try { using (var context = new ReminderDBContext(connectionString)) { return(new ReminderCollection(context.Reminders.ToList())); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static CustomerWarrantyInformedCollection GetCustomerWarrantyInformedList(string connectionString) { try { _connectionString = connectionString; var items = DBContextInstance.CustomerWarrantyInformeds.Select(x => x).ToList(); return(new CustomerWarrantyInformedCollection(items)); } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public IList <String> GetCustomerSearchList(string connectionString, string strSearchText) { try { // using (var context = new CustomerDBContext(connectionString)) { _connectionString = connectionString; return(DBContextInstance.Customers.Where(x => x.FirstName.StartsWith(strSearchText) || x.LastName.StartsWith(strSearchText)).ToList().Select(x => x.FormattedName).ToList()); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static ReminderCollection GetReminders(string connectionString, DateTime?reminderDate) { try { using (var context = new ReminderDBContext(connectionString)) { var items = context.Reminders.Where(x => EntityFunctions.TruncateTime(x.ReminderDate) == EntityFunctions.TruncateTime(reminderDate.Value)); return(new ReminderCollection(items.ToList())); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static AppointmentCollection GetAppointments(string connectionString, DateTime appointmentDate) { try { using (var context = new AppointmentDBContext(connectionString)) { var items = context.Appointments.Where(x => x.AppointmentDate == appointmentDate); return(new AppointmentCollection(items.ToList())); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static UserLoginCollection GetUserLoginList(string connectionString) { try { lock (ThisLock) { _connectionString = connectionString; var items = DBContextInstance.UserLogins.Select(x => x).ToList(); return(new UserLoginCollection(items)); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static bool AddCallLog(string connectionString, CallRegistry callRegistry) { try { using (var context = new CallRegistryDBContext(connectionString)) { context.CallRegistries.Add(callRegistry); var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static bool AddAppointment(string connectionString, Appointment appointment) { try { using (var context = new AppointmentDBContext(connectionString)) { context.Appointments.Add(appointment); var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static bool AddUserLogin(string connectionString, UserLogin userLogin) { try { using (var context = new UserLoginDBContext(connectionString)) { context.UserLogins.Add(userLogin); var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public UserLogin AuthenticateUserLogin(string connectionString, UserLogin userLogin) { try { using (var context = new UserLoginDBContext(connectionString)) { return (context.UserLogins.FirstOrDefault( x => x.LoginName == userLogin.LoginName && x.LoginPassword == userLogin.LoginPassword)); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static CustomerWarrantyInformedCollection GetCustomerWarrantyInformedList(string connectionString, Customer customer) { try { lock (thisRepairLock) { _connectionString = connectionString; var items = DBContextInstance.CustomerWarrantyInformeds.Where(x => x.Customer.ID == customer.ID).OrderByDescending(y => y.InformedDate).ToList(); return(new CustomerWarrantyInformedCollection(items)); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static bool AddReminder(string connectionString, Reminder reminder) { try { using (var context = new ReminderDBContext(connectionString)) { context.Reminders.Add(reminder); 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); } }
private void OnPrintEarMoldReceipt() { try { var childVM = new PrintViewModel(this.Messenger, this.UserLogin, this.Entity.CustomerEarMoldOrderCollection.FirstOrDefault(x => x.IsSelected)) { ParentViewModel = this }; var messageDailog = new VMMessageDailog() { ChildViewModel = childVM }; MessengerInstance.Send(messageDailog); } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); } }
private void GetLocationCollection() { try { using (Stream stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("VH.ViewModel.SupportingFiles.LocationDataBase.txt")) { if (stream != null) { using (var streamReader = new StreamReader(stream)) { var locationCollection = new Dictionary <string, string>(); string line; while ((line = streamReader.ReadLine()) != null) { var location = new Location().GetLocation(line); if (location != null) { if (!locationCollection.ContainsKey(location.CityName)) { locationCollection.Add(location.CityName, location.State); } } _weakRefLocationCollection = new WeakReference(locationCollection); } _weakRefCityCollection = new WeakReference(locationCollection.OrderBy(x => x.Key).Select(x => x.Key).Distinct().ToList()); _weakRefStateCollection = new WeakReference(locationCollection.OrderBy(x => x.Value).Select(x => x.Value).Distinct().ToList()); } } } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); } }