public ActionResult BuildPaganationUtilityList(UtilityList model) { try { return(Json(new { NOP = (new UtilityModel()).BuildPaganationUtilityList(model) }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { error = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetUtilityList(UtilityList model) { try { return(Json((new UtilityModel()).GetUtilityList(model), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { error = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public Sudoku(string name, List <List <int> > rows = null) { if (rows != null) { GridHeight = rows.Count; var x = Convert.ToInt32(Math.Sqrt(GridHeight)); if (x * x == GridHeight) { BlockHeight = x; } else { BlockHeight = GridHeight; } } else { GridHeight = 9; BlockHeight = 3; } Boardname = name; Rows = rows; //transpose Columns = new List <List <int> >(); for (int i = 0; i < GridHeight; i++) { var col = new List <int>(); col = UtilityList.ListRepeatedElements <int>(0, GridHeight); Columns.Add(col); } for (int i = 0; i < GridHeight; i++) { for (int j = 0; j < GridHeight; j++) { Columns[j][i] = Rows[i][j]; } } //calculate coordinates SetBlockToCellCordinateMapping(); //set blocks SetBlocks(); }
private void Edit_UtilityLists_Shown(object sender, EventArgs e) { var factory = SessionConfig.SessionFactory; using (var session = factory.OpenSession()) { //var allUtilityLists = session.Query<UtilityList>().ToDictionary(d=> d.Id, d => d.UtilityListKey); labelCurrentList.Text = CleanUtilityListTitle(ListToEdit); if (ListToEdit != null) { var selectedUtilityList = session.QueryOver <UtilityList>().Where(x => x.UtilityListKey == ListToEdit).SingleOrDefault(); if (selectedUtilityList == null) { using (var transaction = session.BeginTransaction()) { var newUtilityList = new UtilityList() { UtilityListKey = ListToEdit, UtilityListValues = new List <string>() { } }; session.Save(newUtilityList); transaction.Commit(); } //must exist. selectedUtilityList = session.QueryOver <UtilityList>().Where(x => x.UtilityListKey == ListToEdit).SingleOrDefault(); } labelLengthOfList.Text = selectedUtilityList.UtilityListValues.Count().ToString(); selectedUtilityList.UtilityListValues.ForEach(x => listBoxUtilityListItems.Items.Add(x)); ListValues = selectedUtilityList.UtilityListValues.ToList(); ListValues.Sort(); } } }
private void SetBlocks() { var count = -1; // create empty block lists first Blocks = new List <List <int> >(); // first check if there are blocks if (BlockHeight != GridHeight) { count = GridHeight; } else { count = GridHeight * GridHeight; } if (count != -1) { for (int i = 0; i < GridHeight; i++) { var block = new List <int>(); block = UtilityList.ListRepeatedElements <int>(0, count); Blocks.Add(block); } } // second populate block list foreach (KeyValuePair <Tuple <int, int>, Tuple <int, int> > entry in Coordinates) { var cellCoordinates = entry.Key; var blockCoordinates = entry.Value; var value = Rows[cellCoordinates.Item1][cellCoordinates.Item2]; Blocks[blockCoordinates.Item1][blockCoordinates.Item2] = value; } }
private void Edit_UtilityLists_Shown(object sender, EventArgs e) { var factory = SessionConfig.SessionFactory; using (var session = factory.OpenSession()) { //var allUtilityLists = session.Query<UtilityList>().ToDictionary(d=> d.Id, d => d.UtilityListKey); labelCurrentList.Text = CleanUtilityListTitle(ListToEdit); if (ListToEdit != null) { var selectedUtilityList = session.QueryOver<UtilityList>().Where(x => x.UtilityListKey == ListToEdit).SingleOrDefault(); if (selectedUtilityList == null) { using (var transaction = session.BeginTransaction()) { var newUtilityList = new UtilityList() { UtilityListKey = ListToEdit, UtilityListValues = new List<string>() { } }; session.Save(newUtilityList); transaction.Commit(); } //must exist. selectedUtilityList = session.QueryOver<UtilityList>().Where(x => x.UtilityListKey == ListToEdit).SingleOrDefault(); } labelLengthOfList.Text = selectedUtilityList.UtilityListValues.Count().ToString(); selectedUtilityList.UtilityListValues.ForEach(x => listBoxUtilityListItems.Items.Add(x)); ListValues = selectedUtilityList.UtilityListValues.ToList(); ListValues.Sort(); } } }