public HomeScreenViewModel(ProtoBridge bridge, StaffAccountBLL currUser) : base(LibraryScreens.HOME, bridge, currUser) { DisplayName = "Home"; if (currUser == null) LoginAnimationDone = false; if (currUser == null) { LoginBoxVisible = true; AdminButtonsVisible = false; } else { LoginBoxVisible = false; AdminButtonsVisible = true; } Application.Current.Properties["BorrowLimit"] = 15; //For testing // LoginBoxVisible=false; // AdminButtonsVisible = true; }
public ScreenBaseViewModel(LibraryScreens screenType, ProtoBridge bridge, StaffAccountBLL currUser) { ScreenType = screenType; _Bridge = bridge; _CurrentUser = currUser; if (_CurrentUser != null) IsLoggedIn = true; else IsLoggedIn = false; }
public ManipBookDetailsViewModel(ProtoBridge bridge, StaffAccountBLL currUser) : base(LibraryScreens.MANIPULATE_RECORDS, bridge, currUser) { _internalSet = false; _dialogHoster = new DialogHoster(); // _chooseAuthDiagBox = new ChooseAuthorsDialogViewModel _selectedAuthors = new List<ChooseAuthorsDialogViewModel.AuthorSummary>(); ManipulateBar = new ManipulateBarViewModel<BookDetailsBLL>(_Bridge.BookDetailsMgr, OnCurrentItemChanged); OnCurrentItemChanged(); }
public WorkspaceViewModel(ProtoBridge bridge, StaffAccountBLL currUser) { _bridge = bridge; _currentUser = currUser; _activeScreen = new HomeScreenViewModel(bridge, currUser); _activeScreen.ScreenTransition += OnTransition; _activeScreen.LoggedOut += OnLoggedOut; _activeScreen.LoggedIn += OnLoggedIn; ActiveLayer = _activeScreen; PassiveLayer = null; DisplayName = _activeScreen.DisplayName; }
public MemberAccountViewModel(ProtoBridge bridge, StaffAccountBLL currUser) : base(LibraryScreens.TRANSACTIONS, bridge, currUser) { int chosenId = (int)Application.Current.Properties["EnteredMemId"]; _chosenMem = bridge.MemberMgr.GetByID(chosenId); if (_chosenMem == null) { Console.Beep(); } else { MemberID = _chosenMem.ItemID.ToString(); MemberName = _chosenMem.FirstName + " " + _chosenMem.MiddleName + " " + _chosenMem.LastName; TimeSpan ts = DateTime.Now - _chosenMem.JoinDate; Age = (ts.Days/365).ToString(); Address = _chosenMem.Contact.AddressLine1 + " " + _chosenMem.Contact.AddressLine2 + " " + _chosenMem.Contact.AddressLine3 + " " + _chosenMem.Contact.City + " " + _chosenMem.Contact.Pin + " " + _chosenMem.Contact.StateOrProvince + " " + _chosenMem.Contact.Country; Gender = _chosenMem.Gender; JoinDate = _chosenMem.JoinDate.ToString(); List<TransactionBLL> transs = bridge.TransactionMgr.GetMemberTransactions(_chosenMem.ItemID); string err; bridge.TransactionMgr.IssueBook(120, chosenId, out err); if (err != null) MessageBox.Show(err); foreach (TransactionBLL t in transs) { if (t.ReturnedOn == null) TransHistory.Add(new TransactionDetails(bridge, t, true)); else CurrentTrans.Add(new TransactionDetails(bridge, t, false)); } } }
public bool Add(StaffAccountBLL item, out string serverSideError) { serverSideError = null; if (item.IsValid) { using (ProtoLibEntities context = new ProtoLibEntities()) { if (DatabaseDependantValidation(item, context, out serverSideError)) { StaffAccount dalSA = new StaffAccount(); dalSA.AccountPrefs = new AccountPrefs(); CrossLayerEntityConverter.StaffAccountBllToDal(context, item, dalSA); context.StaffAccounts.AddObject(dalSA); context.SaveChanges(); return true; } } } return false; }
bool DatabaseDependantValidation(StaffAccountBLL bllSA, ProtoLibEntities context, out string error, int idToExclude = 0) { error = null; //Check username existance if (UserNameExists(context, bllSA.UserName, bllSA.ItemID)) { error = string.Format("A user already exists with the user-name '{0}'", bllSA.UserName); return false; } if (ValidMemberId(context, bllSA.MemberID) == false) { error = string.Format("No member with ID: {0} exists!", bllSA.MemberID.ToString()); return false; } if (MemberIdAlreadyTaken(context, bllSA.MemberID, bllSA.ItemID)) { error = string.Format("An account already exists for the member with ID: {0}", bllSA.MemberID.ToString()); return false; } return true; }
public bool Update(StaffAccountBLL newItem, out string serverSideError) { if (newItem.IsValid) { using (ProtoLibEntities context = new ProtoLibEntities()) { if (DatabaseDependantValidation(newItem, context, out serverSideError, newItem.ItemID)) { StaffAccount dalSA = (from sa in context.StaffAccounts where sa.AccountID == newItem.ItemID select sa).Single(); CrossLayerEntityConverter.StaffAccountBllToDal(context, newItem, dalSA); context.SaveChanges(); return true; } else return false; } } serverSideError = "Item is in an invalid state!"; return false; }
public StaffAccountBLL GetUserByLoginDetails(string username, string pass) { StaffAccountBLL bllSA = null; using (ProtoLibEntities context = new ProtoLibEntities()) { StaffAccount dalSA = (from sa in context.StaffAccounts where sa.UserName == username && sa.Password == pass select sa).FirstOrDefault(); if (dalSA != null) { bllSA = new StaffAccountBLL(); CrossLayerEntityConverter.StaffAccountDalToBll(context, bllSA, dalSA); } } return bllSA; }
public static void StaffAccountBllToDal(ProtoLibEntities context, StaffAccountBLL bllSA, StaffAccount dalSA) { dalSA.UserName = bllSA.UserName; dalSA.Password = bllSA.Password; dalSA.ClearanceLevel = bllSA.ClearanceLevel; dalSA.Member = context.Members.SingleOrDefault(m => m.MemberID == bllSA.MemberID); dalSA.AccountPrefs.CacheSize = bllSA.Preferences.CacheSize; dalSA.AccountPrefs.SearchResultsPageSize = bllSA.Preferences.SearchResultsPageSize; dalSA.AccountPrefs.FullScreenMode = bllSA.Preferences.FullScreenMode; }
public SearchHostScreenViewModel(ProtoBridge bridge, StaffAccountBLL currUser) : base(LibraryScreens.SEARCH, bridge, currUser) { //_activeSearchScreen = }
private void OnTransition(TransitionPath path, StaffAccountBLL currUser) { ScreenBaseViewModel scr = null; //ALT: Use a Dictionary if this becomes too large switch (path.To) { case LibraryScreens.SEARCH: scr = new SearchHostScreenViewModel(_bridge, currUser); break; case LibraryScreens.HOME: scr = new HomeScreenViewModel(_bridge, currUser); break; //FIXME:Add the proper 4 extra manip enum vals & modify //transition stuff accordingly case LibraryScreens.MANIPULATE_RECORDS: scr = new ManipBookDetailsViewModel(_bridge, currUser); break; case LibraryScreens.TRANSACTIONS_ENTERID: scr = new EnterMemberIdViewModel(_bridge, currUser); break; case LibraryScreens.TRANSACTIONS: scr = new MemberAccountViewModel(_bridge, currUser); break; //etc... } //Set active and passive layers for animation and inform //listener(view) that animation can be performed PassiveLayer = _activeScreen; PassiveLayer.ScreenTransition -= OnTransition; PassiveLayer.LoggedOut -= OnLoggedOut; PassiveLayer.LoggedIn -= OnLoggedIn; _activeScreen = scr; ActiveLayer = _activeScreen; ActiveLayer.ScreenTransition += OnTransition; ActiveLayer.LoggedOut += OnLoggedOut; ActiveLayer.LoggedIn += OnLoggedIn; if (_screenDepthMap[path.To] >= _screenDepthMap[path.From]) InitiateTransitionFSTInwards(this, EventArgs.Empty); else InitiateTransitionFSTOutwards(this, EventArgs.Empty); }
private void OnLoggedOut(object o) { if (this.LoggedOut != null) { _currentUser = null; LoggedOut(o); } }
private void OnLoggedIn(object user) { if (this.LoggedIn != null) { _currentUser = user as StaffAccountBLL; LoggedIn(user); } }
public EnterMemberIdViewModel(ProtoBridge bridge, StaffAccountBLL currUser) : base(LibraryScreens.TRANSACTIONS_ENTERID, bridge, currUser) { BadInput += (o, e) => {}; }
public StaffAccountBLL GetByID(int id) { StaffAccountBLL bllSA = null; using (ProtoLibEntities context = new ProtoLibEntities()) { StaffAccount dalSA = (from sa in context.StaffAccounts where sa.AccountID == id select sa).SingleOrDefault(); if (dalSA != null) { bllSA = new StaffAccountBLL(); CrossLayerEntityConverter.StaffAccountDalToBll(context, bllSA, dalSA); } } return bllSA; }
public List<StaffAccountBLL> GetFirstItems(int numItems) { List<StaffAccountBLL> retList = new List<StaffAccountBLL>(); using (ProtoLibEntities context = new ProtoLibEntities()) { var dalSAs = (from sa in context.StaffAccounts orderby sa.AccountID select sa).Take(numItems); StaffAccountBLL bllSA = null; foreach (StaffAccount dalSA in dalSAs) { bllSA = new StaffAccountBLL(); CrossLayerEntityConverter.StaffAccountDalToBll(context, bllSA, dalSA); retList.Add(bllSA); } } return retList; }
void PerformLogin(object user) { if (user is StaffAccountBLL) { _currentUser = (StaffAccountBLL)user; } }
void PerformMassLogout(object o) { _currentUser = null; Workspaces.Clear(); //HACK: ?? Clean up event handlers? OnWkspcChngd not being called CreateNewWorkspace(); }
public List<StaffAccountBLL> GetPreviousItems(int beforeItemID, int numItems) { List<StaffAccountBLL> retList = new List<StaffAccountBLL>(); using (ProtoLibEntities context = new ProtoLibEntities()) { var dalSAs = (from sa in context.StaffAccounts where sa.AccountID < beforeItemID orderby sa.AccountID descending select sa).Take(numItems); StaffAccountBLL bllSA = null; foreach (StaffAccount dalSA in dalSAs) { bllSA = new StaffAccountBLL(); CrossLayerEntityConverter.StaffAccountDalToBll(context, bllSA, dalSA); retList.Add(bllSA); } } retList.Reverse(); return retList; }
public static void StaffAccountDalToBll(ProtoLibEntities context, StaffAccountBLL bllSA, StaffAccount dalSA) { bllSA.ItemID = dalSA.AccountID; bllSA.UserName = dalSA.UserName; bllSA.Password = dalSA.Password; bllSA.ClearanceLevel = dalSA.ClearanceLevel; bllSA.MemberID = dalSA.MemberID; bllSA.Preferences.CacheSize = dalSA.AccountPrefs.CacheSize; bllSA.Preferences.SearchResultsPageSize = dalSA.AccountPrefs.SearchResultsPageSize; bllSA.Preferences.FullScreenMode = dalSA.AccountPrefs.FullScreenMode; }
protected void PerformLogin(StaffAccountBLL user) { _CurrentUser = user; if (user != null) { IsLoggedIn = true; if (LoggedIn != null) LoggedIn(user); } else IsLoggedIn = false; }