public ActionResult Index() { if (Session["ViewModel"] == null) { SimpleLogger.SimpleLog.Log($"new login"); var login = User.Identity.Name; SimpleLogger.SimpleLog.Log($"new login {login}"); var userName = login.Split('\\')[1]; var model = new TilesModel(); foreach (SiteConfig cfg in AppConfig.SitesConfigs) { if (cfg.CheckAuth(userName)) { model.AllowedSiteCollection.Add(cfg); } else { model.DisallowedSiteCollection.Add(cfg); } } Session["ViewModel"] = model; } return(View(Session["ViewModel"])); }
private void MoveTileToEmptyZone(int index) { TilesModel.MoveTileToEmptyness(index); RefreshView(); Moves++; CheckWinsCondition(); }
public ModifiledTileAction(int newTileIndex, int rIndex, int cIndex, TilesModel matrixObject) { this.oldTileIndex = matrixObject.Matrix[rIndex, cIndex]; this.newTileIndex = newTileIndex; this.rIndex = rIndex; this.cIndex = cIndex; this.matrixObject = matrixObject; }
private void CheckWinsCondition() { if (TilesModel.IsInOrder()) { MessageBox.Show($"Total moves: {Moves}", "Game completed!", MessageBoxButton.OK); Rows = 0; Moves = 0; } }
public AddDevicesViewModel() { this.Account = new AccountModel() { Email = App.SessionAccount }; newTiles = new TilesModel(); client = new FireSharp.FirebaseClient(config); AddCommand = new RelayCommand(o => AddNewDevices(this.Account)); CloseCommand = new RelayCommand(o => BackAction()); MouseDownCommand = new RelayCommand(o => DragWindow()); ButtonEnable = "True"; }
public async void ChangeTilesStatus(AccountModel account, TilesModel data, string FromState) { try { if (Convert.ToInt32(SelectedTilesIndex) > 0) { string username = account.Email.Substring(0, account.Email.IndexOf("@")); data = data ?? new TilesModel(); data.Status = FromState.Equals("ON") ? "OFF" : "ON"; int index = Convert.ToInt32(SelectedTilesIndex); Tiles[index].Status = data.Status; FirebaseResponse response = await client.UpdateAsync <TilesModel>("/Account/" + username + "/Tiles/" + SelectedTilesIndex + "/", data); TilesModel result = response.ResultAs <TilesModel>() ?? new TilesModel(); OnPropertyChanged(nameof(Tiles)); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void StartNewGame() { _tilesModel = new TilesModel(Rows); Moves = 0; RefreshView(); }
public void ModifiedTile(int newTileIndex, int rIndex, int cIndex, TilesModel matrixObject) { var action = new ModifiledTileAction(newTileIndex, rIndex, cIndex, matrixObject); HandlePushAction(action); }
public TilesViewModel(TilesModel model) { _model = model; Id = model.ID; }