// GET: AvailableSpace/Edit/5 public ActionResult Edit(string id) { AvailableSpaceBusinessLayer sbl = new AvailableSpaceBusinessLayer(); AvailableSpace sa = sbl.AvailableSpaces.Where(i => i.ID == id).Single(); GradeBusinessLayer gbl = new GradeBusinessLayer(); List <Grade> ListOfGrades = gbl.Grades.ToList(); SeasonBusinessLayer ebl = new SeasonBusinessLayer(); List <Season> ListOfSeasons = ebl.Seasons.ToList(); SpaceBusinessLayer spbl = new SpaceBusinessLayer(); List <Space> ListOfSpaces = spbl.Spaces.ToList(); CatBusinessLayer cbl = new CatBusinessLayer(); List <Cat> ListOfCats = cbl.Cats.Where(w => w.CatActive == 1).ToList(); ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem { Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == sa.SeasonID }); ViewData["ddGrade"] = ListOfGrades.Select(m => new SelectListItem { Value = m.GradeID.ToString(), Text = m.GradeDescription, Selected = m.GradeID == sa.SpaceGradeID }); ViewData["ddCat"] = ListOfCats.Select(m => new SelectListItem { Value = m.CatID.ToString(), Text = m.CatDesc + " (" + m.CatID.ToString() + ")", Selected = m.CatID == sa.CatID }); ViewData["ddSpace"] = ListOfSpaces.Select(m => new SelectListItem { Value = m.SpaceID.ToString(), Text = m.SpaceDesc + " (" + m.SpaceID.ToString() + ")", Selected = m.SpaceID == sa.SpaceID }); return(View(sa)); }
public ActionResult Delete(string id, FormCollection collection) { bool DidItWork = false; try { AvailableSpaceBusinessLayer sbl = new AvailableSpaceBusinessLayer(); AvailableSpace sa = sbl.AvailableSpaces.Where(i => i.ID == id).Single(); StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer(); DidItWork = spbl.ExecuteStoredProcedure(sa, "Edit", User.Identity.Name); if (DidItWork == false) { return(Content("Error on deletion of available space. Press back to return and try again")); } else { return(RedirectToAction("Index", new { SeasonID = sa.SeasonID, GradeID = sa.SpaceGradeID, CatID = sa.CatID })); } } catch { return(View()); } }
public ActionResult Create(FormCollection collection) { bool DidItWork = false; try { AvailableSpace a = new AvailableSpace(); a.SeasonID = Convert.ToInt32(collection["ddSeason"]); a.SpaceID = Convert.ToInt32(collection["ddSpace"]); a.CatID = Convert.ToInt32(collection["ddCat"]); a.SpaceGradeID = Convert.ToInt32(collection["ddGrade"]); //AvailableSpaceBusinessLayer bl = new AvailableSpaceBusinessLayer(); //DidItWork = bl.ActionAvailableSpace(a, "Create", User.Identity.Name); StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer(); DidItWork = spbl.ExecuteStoredProcedure(a, "Create", User.Identity.Name); if (DidItWork == false) { //something went wrong trying to action the PreArticalSeasonald procedure //return View(); return(Content("Error on creation of Available Space. Press back to return and try again")); } else { //return View(); return(RedirectToAction("Index", "AvailableSpace", new { SeasonID = a.SeasonID, CatID = a.CatID, SpaceID = a.SpaceID, GradeID = a.SpaceGradeID })); } } catch (Exception x) { return(View()); } }
/// <summary> /// Grow available rectangles from given origin. /// Returns a list of found rectangles. /// An available rectangle is a possible rectangle on page that doesn't contain any item or item part. /// </summary> /// <param name="origin">Origin from where to grow possible rectangles.</param> /// <seealso cref="AvailableSpace"/> /// <returns>A list of available spaces.</returns> private List <AvailableSpace> GrowFromOrigin(Vector2 origin) { List <AvailableSpace> potential_spaces = new List <AvailableSpace>(); // Define max x as page width. int max_x = width; int y = (int)origin.y; // While y is less than page height AND not item has been on the way. while (y < height && PlaceAvailable(new Vector2(origin.x, y)) == true) { // Reset x to origin.x int x = (int)origin.x; // Loop until a placed item is met. while (x < max_x && PlaceAvailable(new Vector2(x, y)) == true) { x = x + 1; } // Update max_x as the rectangle won't be allowed to go further. max_x = x; // Create a new AvailableSpace based on that data. AvailableSpace new_space = new AvailableSpace(origin, new Vector2(x, y + 1) - origin); if (new_space.size.x > 0 && new_space.size.y > 0) { // Add found rectangle as a potential space. potential_spaces.Add(new_space); } y = y + 1; } return(potential_spaces); }
public override int GetHashCode() { int hash = 1; if (ZmqHost.Length != 0) { hash ^= ZmqHost.GetHashCode(); } if (ZmqPort.Length != 0) { hash ^= ZmqPort.GetHashCode(); } if (TotalSpace != 0UL) { hash ^= TotalSpace.GetHashCode(); } if (AvailableSpace != 0UL) { hash ^= AvailableSpace.GetHashCode(); } if (HttpPort.Length != 0) { hash ^= HttpPort.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
// GET: AvailableSpace/Delete/5 public ActionResult Delete(string id) { AvailableSpaceBusinessLayer sbl = new AvailableSpaceBusinessLayer(); AvailableSpace sa = sbl.AvailableSpaces.Where(i => i.ID == id).Single(); int MaxFO = sbl.AvailableSpaces.Where(i => i.SeasonID == sa.SeasonID && i.SpaceID == sa.SpaceID && i.SpaceGradeID == sa.SpaceGradeID && i.CatID == sa.CatID).Max(e => e.FixtureOrdinal); sa.FixtureOrdinal = MaxFO; string RedoneID = sa.ID; AvailableSpace saRedone = sbl.AvailableSpaces.Where(i => i.ID == RedoneID).Single(); return(View(saRedone)); }
/// <summary> /// Reorders _available_spaces list to get bottom left spaces first. /// </summary> private void OrderAvailableSpaces() { // Simple bubble sort. for (int i = 1; i < _available_spaces.Count; ++i) { AvailableSpace left = _available_spaces[i - 1]; AvailableSpace right = _available_spaces[i]; if (left.origin.y > right.origin.y) { _available_spaces[i - 1] = right; _available_spaces[i] = left; i = 0; } } }