public ReportViewModel() { if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) { return; } Context = new NiagaposEntities(); DataReportItems = new ObservableCollection <DataReportModel>(); SelectedItems = new DataReportModel(); LoadData(); SetupCommand(); }
/// <summary> /// Default constructor. /// </summary> public DashboardViewModel() { if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) { return; } Context = new NiagaposEntities(); SeriesCollection = new SeriesCollection(); SeriesCollectionPie = new SeriesCollection(); DataLoadedCommand = new RelayCommand(() => DataLoaded()); LoadChart(); LoadDoughnutChart(); }
public void InitializeCollection() { OrderListItemsCollection = new ObservableCollection <OrderListItemModel>(); Context = new NiagaposEntities(); GetOrderListItemModel = new OrderListItemModel(); ProductListItemsCollection = new ObservableCollection <ProductListItemModel>(); GetProductListItemModel = new ProductListItemModel(); ConfirmOrderListItemsCollection = new ObservableCollection <ConfirmOrderListItemModel>(); GetConfirmOrderListItemModel = new ConfirmOrderListItemModel(); TransactionListItemsCollection = new ObservableCollection <TransactionDetailViewModel>(); GetTransactionListItemsModel = new TransactionDetailViewModel(); TransactionModelCollection = new ObservableCollection <Transaction>(); GetTransactionModel = new Transaction(); TransactionDetailModelCollection = new ObservableCollection <TransactionDetail>(); GetTransactionDetailModel = new TransactionDetail(); }
/// <summary> /// Attempts to log the user in /// </summary> /// <param name="parameter">The <see cref="SecureString"/> passed in from the view for the users password</param> /// <returns></returns> public async Task LoginAsync(object parameter) { await RunCommandAsync(() => LoginIsRunning, async() => { try { using (var Context = new NiagaposEntities()) { UnsecurePassword = (parameter as IHavePassword).SecurePassword.Unsecure(); if (UnsecurePassword == "" && Username == null) { await DI.UI.ShowMessage(new MessageBoxDialogViewModel { Title = "Message", Message = "Silakan masukan Username dan Password Anda", }); } else if (UnsecurePassword == "" || UnsecurePassword == null) { await DI.UI.ShowMessage(new MessageBoxDialogViewModel { Title = "Message", Message = "Password masih kosong, silakan isi terlebih dahulu", }); } else if (Username == null || Username == "") { await DI.UI.ShowMessage(new MessageBoxDialogViewModel { Title = "Message", Message = "Username masih kosong, silakan isi terlebih dahulu", }); } else { UnsecurePassword = PasswordEncryptions.EncryptToMD5Cryptography(UnsecurePassword); var query = from user in Context.Users join access in Context.UserAccesses on user.UserAccessId equals access.UserAccessId where user.Username == Username.Trim() && user.Password == UnsecurePassword.Trim() select new { user.Name, user.Username, user.Password, access.Caption, }; var list = new List <User>(); var query2 = (from user in Context.Users where user.Username == Username.Trim() && user.Password == UnsecurePassword.Trim() orderby user.UserId select user).ToList(); foreach (var user in query2.ToList()) { list.Add(new User { Username = user.Username, Password = user.Password }); } if (query.SingleOrDefault() != null) { foreach (var user in query.ToList()) { DI.UserCredential.Caption = user.Caption; DI.UserCredential.Name = user.Name; DI.Transaction.User = user.Name; } DI.Application.GoToPage(ApplicationPage.Dashboard); await Task.Delay(TimeSpan.FromSeconds(1)); } else { await DI.UI.ShowMessage(new MessageBoxDialogViewModel { Title = "Message", Message = "Username atau Password Anda salah, silakan coba lagi", }); } } } } catch (Exception ex) { CoreDI.Logger.Log(ex.Message); } await Task.Delay(TimeSpan.FromSeconds(1)); }); }