示例#1
0
        public void OpenFloorPlan(FloorPlan floorPlan)
        {
            ProjectOverviewViewModel vm = DataContext as ProjectOverviewViewModel;

            FloorPlanGrid floorPlanGrid = new FloorPlanGrid(floorPlan, vm.ProjectFile);

            floorPlanGrid.ChangeObserved += FloorPlanGrid_ChangeObserved;
            //floorPlanGrid.FloorNameChanged += PlanGrid_NameChanged;

            tabControl.SelectedIndex = AddTab(floorPlanGrid, floorPlan.Name, floorTabStyle, Guid.NewGuid().ToString());
            SetCurrentTabItemBold(tabControl.Items[tabControl.SelectedIndex] as TabItem);
        }
        public static void AttachFloorItemHtmlDesign(this Controller controller, FloorPlan plan, ICacheManager cache)
        {
            var floorItems = plan.FloorTables;

            foreach (var item in floorItems)
            {
                item.TableDesign = cache.Get<string>(string.Format(CacheKeys.FLOOR_PLAN_TABLE_DESIGN,controller.User.Identity.GetDatabaseName(),item.FloorTableId), () =>
                {
                    return controller.RenderPartialViewToString("~/Views/Floor/GetFloorItemTemplate.cshtml", item);
                });
            }
        }
示例#3
0
    private bool overlaps(FloorPlan other)
    {
        int x2 = x + width;
        int z2 = z + height;

        int ox  = other.x;
        int oz  = other.z;
        int ox2 = other.x + other.width;
        int oz2 = other.z + other.height;

        return(!(((x > ox2 || ox > x2) || (z > oz2 || oz > z2))));
    }
示例#4
0
        public void TestStartTileUnwalkable() // test block size of 5
        {
            FloorPlan image1 = new FloorPlan(new Bitmap("../../testImage.jpg"), 5);
            bool      result = image1.setStartTile(3, 6);
            FloorTile tile   = image1.getTile(3, 6);
            bool      t_res  = tile.IsStart();
            bool      t_res2 = tile.IsTarget();

            Assert.AreEqual(false, result);
            System.Diagnostics.Debug.WriteLine("Start:" + t_res);
            System.Diagnostics.Debug.WriteLine("Target:" + t_res2);
        }
示例#5
0
        static bool Prefix(FloorPlan floorPlan, ref bool __result)
        {
            if (!Main.enabled)
            {
                return(true);
            }

            if (floorPlan.Width() >= 1 && floorPlan.Height() >= 1)
            {
                __result = true;
            }
            return(false);
        }
 static int CorrectLength(int x, int z, FloorPlan floorPlan, int tmpRoomLength)
 {
     for (int i = z; i < z + tmpRoomLength; i++)
     {
         if (floorPlan.roomData [x, i] != null)
         {
             //Wenn ein Raum im Weg ist
             return(i - z - 1);
             //return floorPlan;
         }
     }
     return(tmpRoomLength);
 }
示例#7
0
        private void loadFloorPlan(FloorPlan fp)
        {
            FileInfo f = new FileInfo(fp.picture);

            if (!f.Exists)
            {
                fpView.Image = media.getImage(fp.picture);
            }
            else
            {
                fpView.Image = Image.FromFile(fp.picture);
            }
        }
示例#8
0
        public int SolvePuzzlePart2(string input)
        {
            string[] lines = input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            FloorPlan        floorPlan     = new FloorPlan();
            List <VisitNode> placesToVisit = new List <VisitNode>();

            ParseInput(lines, floorPlan, placesToVisit);

            PuzzleController pc = new PuzzleController();

            return(pc.SolvePuzzle(floorPlan, placesToVisit, true));
        }
        internal static FloorPlanVm MapToFloorPlanVm(this FloorPlan floorPlan)
        {
            FloorPlanVm floorPlanQuickViewVm = floorPlan.MapToFloorPlanQuickViewVm(new FloorPlanVm()) as FloorPlanVm;

            if (floorPlanQuickViewVm != null)
            {
                floorPlanQuickViewVm.Deposit        = floorPlan.Deposit.PriceCaption();
                floorPlanQuickViewVm.ApplicationFee = floorPlan.ApplicationFee.PriceCaption();
                floorPlanQuickViewVm.PetDeposit     = floorPlan.PetDeposit.PriceCaption();
                floorPlanQuickViewVm.Amenities      = floorPlan.Amenities;
            }
            return(floorPlanQuickViewVm);
        }
示例#10
0
        public void TestConnectBlockFive()
        {
            FloorPlan image1 = new FloorPlan(new Bitmap("../../testImage.jpg"));

            int width  = image1.getXTileNum();
            int height = image1.getYTileNum();

            System.Diagnostics.Debug.WriteLine("Height " + height + " Width " + width);
            FloorTile tile = image1.getTile(2, 4);
            FloorTile n1, n2, n3, n4;

            System.Diagnostics.Debug.WriteLine("");
            List <FloorTile> neighbour = tile.getNeighbours();

            if (neighbour.Count > 3)
            {
                n1 = neighbour[0];
                n2 = neighbour[1];
                n3 = neighbour[2];
                n4 = neighbour[3];
                System.Diagnostics.Debug.WriteLine("1st \t" + n1.Position.X + "\t" + n1.Position.Y + "\t" + n1.Iswalkable());
                System.Diagnostics.Debug.WriteLine("2nd \t" + n2.Position.X + "\t" + n2.Position.Y + "\t" + n2.Iswalkable());
                System.Diagnostics.Debug.WriteLine("3rd \t" + n3.Position.X + "\t" + n3.Position.Y + "\t" + n3.Iswalkable());
                System.Diagnostics.Debug.WriteLine("4th \t" + n4.Position.X + "\t" + n4.Position.Y + "\t" + n4.Iswalkable());
            }
            else if (neighbour.Count == 3)
            {
                n1 = neighbour[0];
                n2 = neighbour[1];
                n3 = neighbour[2];
                System.Diagnostics.Debug.WriteLine("1st \t" + n1.Position.X + "\t" + n1.Position.Y + "\t" + n1.Iswalkable());
                System.Diagnostics.Debug.WriteLine("2nd \t" + n2.Position.X + "\t" + n2.Position.Y + "\t" + n2.Iswalkable());
                System.Diagnostics.Debug.WriteLine("3rd \t" + n3.Position.X + "\t" + n3.Position.Y + "\t" + n3.Iswalkable());
            }
            else if (neighbour.Count == 2)
            {
                n1 = neighbour[0];
                n2 = neighbour[1];
                System.Diagnostics.Debug.WriteLine("1st \t" + n1.Position.X + "\t" + n1.Position.Y + "\t" + n1.Iswalkable());
                System.Diagnostics.Debug.WriteLine("2nd \t" + n2.Position.X + "\t" + n2.Position.Y + "\t" + n2.Iswalkable());
            }
            else if (neighbour.Count == 1)
            {
                n1 = neighbour[0];
                System.Diagnostics.Debug.WriteLine("1st \t" + n1.Position.X + "\t" + n1.Position.Y + "\t" + n1.Iswalkable());
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("No Walkable Neighbours");
            }
        }
示例#11
0
        private static void DrawFloorPlan(FloorPlan fp)
        {
            int width = 252, height = 252;

            Brush[] brushes = new Brush[]
            {
                Brushes.Gray,
                Brushes.DarkGray,
                Brushes.LightGray,
                Brushes.LightSlateGray,
                Brushes.BurlyWood
            };

            // Create our canvas to work with
            var font = new Font("Arial", 8);
            var bmp  = new Bitmap(width, height);
            var gfx  = Graphics.FromImage(bmp);

            gfx.FillRectangle(Brushes.White, new RectangleF(0, 0, width, height));

            // Draw rooms and their types
            for (int i = 0; i < fp.Rooms.Count; i++)
            {
                var r = fp.Rooms[i];

                gfx.FillRectangle(brushes[i % brushes.Length], r.X, r.Y, r.Width, r.Height);
                gfx.DrawRectangle(Pens.Black, new Rectangle(new Point(r.X, r.Y), new Size(r.Width, r.Height)));

                gfx.DrawString(r.Type.ToString(), font, Brushes.Black, r.X, r.Y);
            }

            // Display form
            var form = new Form()
            {
                AutoSize = true
            };

            form.Controls.Add
            (
                new PictureBox()
            {
                Width    = width,
                Height   = height,
                Image    = bmp,
                Location = new Point(5, 5)
            }
            );

            form.ShowDialog();
        }
示例#12
0
 /**
  * Attempt to add a given floorplan. Will fail if there are any existing
  * floorplans that overlap this one.
  */
 public static bool add(FloorPlan plan)
 {
     Debug.Log("Trying to add plan: x=" + plan.x + " z=" + plan.z + " w=" + plan.width + " h=" + plan.height);
     if (floorPlans.TrueForAll(p => !p.overlaps(plan)))
     {
         floorPlans.Add(plan);
         return(true);
     }
     else
     {
         Debug.Log("Failed to add floorplan.");
         return(false);
     }
 }
        public void FloorPlan_displays_paths()
        {
            var plan = new FloorPlan();

            plan.FloorTiles.AddRange(_FillArea(2, 2));

            var path = new List <Location>();

            path.Add(new Location(0, 0));
            path.Add(new Location(1, 1));
            string display = plan.Print(path);

            Debug.Write(display);
            display.ShouldBeEquivalentTo("A+" + Environment.NewLine + "+B" + Environment.NewLine);
        }
        public FloorPlanGrid(FloorPlan floorPlan, ProjectFile projectFile)
        {
            InitializeComponent();
            floorPlan.FloorNameChanged             += FloorPlan_FloorNameChanged;
            floorPlan.NameChanged                  += FloorPlan_FloorNameChanged;
            floorPlan.ChangeManager.ChangeObserved += ChangeManager_ChangeObserved;
            this.projectFile = projectFile;

            FloorPlanViewModel vm = DataContext as FloorPlanViewModel;

            vm.ProjectFile = projectFile;
            floorPlan.Load();
            vm.FloorPlan = floorPlan;
            AddRooms();
        }
示例#15
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FloorPlan = await _context.FloorPlan.FirstOrDefaultAsync(m => m.FloorPlanID == id);

            if (FloorPlan == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public void FloorPlan_detects_tiles()
        {
            FloorPlan plan = NSubstitute.Substitute.For <FloorPlan>();

            plan.GetFloorTile(10, 1).Should().BeNull();

            plan.FloorTiles.AddRange(_FillArea(30, 10, 1));
            plan.GetFloorTile(20, 1).Cost.Value.ShouldBeEquivalentTo(1);

            plan.GetFloorTile(10, 2).Cost = 5;
            plan.GetFloorTile(10, 2).Cost.Value.ShouldBeEquivalentTo(5);

            plan.GetFloorTile(30, 0).Should().BeNull();
            plan.GetFloorTile(0, 10).Should().BeNull();
        }
示例#17
0
        /// <summary>
        ///get executing time for a path
        ///</summary>
        public void visualizeFloorPlan(FloorPlan floorPlan, int StartX, int StartY, int TargetX, int TargetY)
        {
            floorPlan.setStartTile(StartX, StartY);
            floorPlan.setTargetTile(TargetX, TargetY);
            QGPathFinder     target = new QGPathFinder(floorPlan);
            List <FloorTile> actual;

            actual = target.getPath();

            Form f = new WindowsFormsApplication1.Form1(floorPlan, actual);

            Application.Run(f);

            //f.Invoke();
            //f.Draw(floorPlan, actual);
        }
示例#18
0
        public void NavigationService_works()
        {
            var plan = new FloorPlan();

            plan.FloorTiles.AddRange(_FillArea(20, 10, 1));
            plan.GetFloorTile(1, 0).Cost = 3;
            plan.GetFloorTile(0, 1).Cost = 2;
            plan.GetFloorTile(1, 1).Cost = 2;
            plan.GetFloorTile(1, 8).Cost = 3;
            plan.GetFloorTile(0, 8).Cost = 3;

            NavigationService service = NSubstitute.Substitute.For <NavigationService>(plan);
            var path = service.FindPath(new Location(0, 0), new Location(14, 8));

            Debug.Write(plan.Print(path));
        }
        //
        // GET: /FloorPlan/Edit/5

        public ActionResult Edit(int id = 0)
        {
            var query = _db.Series.Select(c => new { c.Id, c.Name });

            ViewData["listSeries"] = new SelectList(query.AsEnumerable(), "Id", "Name");

            //ViewData["listSeries"] = GetSeries();

            FloorPlan floorplan = _db.FloorPlans.Find(id);

            if (floorplan == null)
            {
                return(HttpNotFound());
            }
            return(View(floorplan));
        }
        public void FloorPlan_detects_agents()
        {
            FloorPlan plan = new FloorPlan();            //NSubstitute.Substitute.For<FloorPlan>();

            plan.FloorTiles.AddRange(_FillArea(30, 10, 1));
            plan.IsAgentOnTile(11, 4).Should().BeFalse();

            var agent = new Agent();            // NSubstitute.Substitute.For<IAgent>();

            agent.Move(new Location(11, 4));

            plan.AddAgent("Test Agent", agent);
            plan.IsAgentOnTile(11, 4).Should().BeTrue();

            plan.IsAgentOnTile(4, 11).Should().BeFalse();
        }
示例#21
0
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            RefillBrushQueue();
            fp = new FloorPlan(fpWidth, fpHeight, fpMaxRooms, fpMaxRoomsPerGroup, fpMaxRoomSize, fpMaxLargeRooms, fpBlueprintSections, fpfootprintlength, fpfootprintwidth, doPause);
            try
            {
                mainThread = new Thread(fp.GenerateFloorPlan);
                mainThread.Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.WriteLine("Done");
        }
示例#22
0
        public void FloorPlanBuildingBlockNeighbourTest()
        {
            FloorPlan floorPlan = new FloorPlan();

            floorPlan.CreateFloorPlan(3, 3, 1, "test", new[] { "1" });
            floorPlan.Initiate();
            Assert.AreEqual(9, floorPlan.BuildingBlocks.Count);
            Assert.AreEqual(9, floorPlan.Tiles.Count);
            BuildingBlock block;

            floorPlan.BuildingBlocks.TryGetValue(Coordinate(1, 1, 0), out block);
            Assert.AreNotEqual(null, block);
            Assert.AreEqual(8, block.BuildingBlockNeighbours.Count);

            BuildingBlock otherBlock;
            int           x = 0, y = 0;

            foreach (BuildingBlock buildingBlock in block.BuildingBlockNeighbours)
            {
                if (x == 1 && y == 1)
                {
                    x++;
                }
                floorPlan.BuildingBlocks.TryGetValue(Coordinate(x, y, 0), out otherBlock);
                Assert.AreNotEqual(null, otherBlock);
                Assert.AreEqual(otherBlock, buildingBlock);
                x++;
                if (x == 3)
                {
                    x = 0;
                    y++;
                }
            }
            Assert.AreEqual(0, x);
            Assert.AreEqual(3, y);

            floorPlan.BuildingBlocks.TryGetValue(Coordinate(0, 0, 0), out block);
            Assert.AreNotEqual(null, block);
            Assert.AreEqual(3, block.BuildingBlockNeighbours.Count);

            floorPlan.BuildingBlocks.TryGetValue(Coordinate(1, 0, 0), out otherBlock);
            Assert.IsTrue(block.BuildingBlockNeighbours.Any(b => Equals(b, otherBlock)));
            floorPlan.BuildingBlocks.TryGetValue(Coordinate(0, 1, 0), out otherBlock);
            Assert.IsTrue(block.BuildingBlockNeighbours.Any(b => Equals(b, otherBlock)));
            floorPlan.BuildingBlocks.TryGetValue(Coordinate(1, 1, 0), out otherBlock);
            Assert.IsTrue(block.BuildingBlockNeighbours.Any(b => Equals(b, otherBlock)));
        }
        public ActionResult Edit(FloorPlan floorplan, FormCollection selectedSeries)
        {
            if (ModelState.IsValid)
            {
                string label = selectedSeries["SeriesId"];
                int    i     = 0;

                Int32.TryParse(label, out i);



                //FloorPlan floorplanEdited = _db.FloorPlans.Find(floorplan.Id);
                //if (floorplanEdited == null)
                //{
                //    return HttpNotFound();
                //}

                //floorplanEdited.SeriesLabel = _db.Series.Find(i);


                //_db.Entry(floorplan).State = EntityState.Modified;
                //_db.SaveChanges();

                FloorPlan floorplanEdited = _db.FloorPlans.Find(floorplan.Id);
                if (floorplanEdited == null)
                {
                    return(HttpNotFound());
                }

                floorplanEdited.Baths      = floorplan.Baths;
                floorplanEdited.Beds       = floorplan.Beds;
                floorplanEdited.ModelNum   = floorplan.ModelNum;
                floorplanEdited.OurPrice   = floorplan.OurPrice;
                floorplanEdited.TheirPrice = floorplan.TheirPrice;
                floorplanEdited.Sections   = floorplan.Sections;
                floorplanEdited.Size       = floorplan.Size;
                floorplanEdited.Sqft       = floorplan.Sqft;

                floorplanEdited.SeriesLabel = _db.Series.Find(i);


                _db.Entry(floorplanEdited).State = EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(floorplan));
        }
 private void LoadGeometry(string fileName)
 {
     try
     {
         using (Stream stream = File.Open(fileName, FileMode.Open))
         {
             BinaryFormatter bf        = new BinaryFormatter();
             FloorPlan       floorPlan = new FloorPlan();
             floorPlan       = (FloorPlan)bf.Deserialize(stream);
             drawnRectangles = floorPlan.rectList;
             drawnLines      = floorPlan.lines;
             ListRectCorners = floorPlan.ListRectCorners;
         }
     }
     catch (IOException ex)
     { MessageBox.Show("Error: " + ex.Message); }
 }
示例#25
0
        public Map(FloorPlan fPlan)
        {
            Name      = fPlan.Name;
            ImageName = fPlan.ImageName;

            MapFloorPlan = fPlan;

            foreach (Room nRoom in fPlan.Rooms)
            {
                RoomsInMap.Add(new MapRoom(nRoom));
            }

            foreach (Connection nConnection in fPlan.Connections)
            {
                AddEdge(nConnection);
            }
        }
示例#26
0
        public void Refresh(FloorPlan floorPlan)
        {
            FloorPlan = floorPlan;
            MaxRow    = floorPlan.FloorTiles.Max(x => x.Y);
            MaxCol    = floorPlan.FloorTiles.Max(x => x.X);

            Weight = new decimal[MaxCol + 1, MaxRow + 1];

            for (int row = 0; row <= MaxRow; row++)
            {
                for (int col = 0; col <= MaxCol; col++)
                {
                    var tile = floorPlan.GetFloorTile(col, row);
                    Weight[col, row] = tile?.Cost ?? 0;
                }
            }
        }
示例#27
0
        public void getPathVisualizationTest()
        {
            Image     myimage   = new Bitmap("../../testImage.jpg");
            FloorPlan floorPlan = new FloorPlan(myimage, 5);
            int       StartX    = 8;
            int       StartY    = 8;
            int       TargetX   = 40;
            int       TargetY   = 20;

            TextWriter tw = new StreamWriter("../../ExecutingTimeVis.txt");
            Int64      t  = getPathExecutingTime(floorPlan, StartX, StartY, TargetX, TargetY);

            tw.WriteLine(StartX + "," + StartY + "," + TargetX + "," + TargetY + "," + t);
            tw.Close();

            //visualizeFloorPlan(floorPlan, StartX, StartY, TargetX, TargetY);
        }
示例#28
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FloorPlan = await _context.FloorPlan.FindAsync(id);

            if (FloorPlan != null)
            {
                _context.FloorPlan.Remove(FloorPlan);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        private void SaveGeometry(string fileName)
        {
            FloorPlan floorPlan = new FloorPlan();

            floorPlan.lines           = drawnLines;
            floorPlan.rectList        = drawnRectangles;
            floorPlan.ListRectCorners = ListRectCorners;
            try
            {
                using (Stream stream = File.Open("./Layouts/serialized/" + fileName + ".bin", FileMode.Create))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    bf.Serialize(stream, floorPlan);
                }
            }
            catch (IOException ex)
            { MessageBox.Show("Error: {" + ex.Message + "}"); }
        }
        public void FloorPlan_displays_costs()
        {
            var plan = new FloorPlan();

            plan.FloorTiles.Add(new FloorTile(0, 0));
            plan.FloorTiles.Add(new FloorTile(1, 0, cost: -1));
            plan.FloorTiles.Add(new FloorTile(2, 0, cost: 1));
            plan.FloorTiles.Add(new FloorTile(3, 0, cost: 2));
            plan.FloorTiles.Add(new FloorTile(4, 0, cost: 3));
            plan.FloorTiles.Add(new FloorTile(0, 1, cost: 4));
            plan.FloorTiles.Add(new FloorTile(2, 1, cost: 6));
            plan.FloorTiles.Add(new FloorTile(3, 1, cost: 99));
            plan.FloorTiles.Add(new FloorTile(1, 1, cost: 5));

            string display = plan.Print();

            Debug.Write(display);
            display.ShouldBeEquivalentTo("++_23" + Environment.NewLine + "456X+" + Environment.NewLine);
        }
示例#31
0
        public void MySerializer()
        {
            Image     myimage = new Bitmap("../../testImage.jpg"); // TODO: Initialize to an appropriate value
            FloorPlan target  = new FloorPlan(myimage);            // TODO: Initialize to an appropriate value
            //  XmlSerializer s = new XmlSerializer(typeof (FloorPlan));
            String testFileName = "../../testImage.xml";

            using (Stream s = File.Open(testFileName, FileMode.Create))
            {
                SoapFormatter formatter = new SoapFormatter();
                formatter.Serialize(s, target);
            }

            target = null;
            using (Stream s = File.Open(testFileName, FileMode.Open))
            {
                SoapFormatter formatter = new SoapFormatter();
                target = (FloorPlan)formatter.Deserialize(s);
            }
        }
示例#32
0
        public void SaveAsGridFile(string filePath)
        {
            Dictionary<string, Tile> theTiles = new Dictionary<string, Tile>();
            for (int y = 0; y < ImageHeight; y++)
            {
                for (int x = 0; x < ImageWidth; x++)
                {
                	// Decides the Tile.Type based on the ConstrastSliders value.
                    Tile.Types theType;
                    if (SobelFilterActivated)
                        theType = _pixelsCurrentlyActive[y, x] >= ParentWindow.CpImageScanControls.ContrastSlider.Value ? Tile.Types.Wall: Tile.Types.Free;
                    else
                        theType = _pixelsCurrentlyActive[y, x] <= ParentWindow.CpImageScanControls.ContrastSlider.Value ? Tile.Types.Wall : Tile.Types.Free;

                    Tile currentTile = new Tile(x, y, 0, theType);

                    theTiles.Add(Coordinate(currentTile), currentTile);   
                }
            }
            // Creates a floorplan for use with the ExportBuilding function.
            // The filepath is read from the filepath field in the window.
            IFloorPlan theFloorPlan = new FloorPlan();
            theFloorPlan.CreateFloorPlan(ImageWidth, ImageHeight, theTiles);
            Export.ExportBuilding(filePath, theFloorPlan, new Dictionary<int, Person>());
        }
示例#33
0
        private void AttachFloorItemHtmlDesign(FloorPlan plan)
        {
            var floorItems = plan.FloorTables;

            foreach (var item in floorItems)
            {
                item.TableDesign = this.RenderPartialViewToString("GetFloorItemTemplate", item);
            }
        }
示例#34
0
        public ActionResult SaveFloor(TempFloorPlan model)
        {
            var fp = Db.tabTempFloorPlans.Include("TempFloorTables").Where(p => p.FloorPlanId == model.FloorPlanId).Single();

            var isFloorActive = Db.tabFloorPlans;
            int[] lvl = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            int flvl;
            if (isFloorActive.Count() == 0)
            {
                flvl = 1;
            }
            else
            {
                flvl = lvl.Where(p => !isFloorActive.Select(s => s.FLevel).ToList().Contains(p)).FirstOrDefault();
            }

            var floorPlan = new FloorPlan()
            {
                CreatedOn = fp.CreatedOn,
                FloorName = model.FloorName,
                PhotoPath = fp.PhotoPath,
                UserId = fp.UserId,
                FLevel = flvl,
                IsActive = isFloorActive.Count() == 0 ? true : false,

                UpdatedBy = User.Identity.GetUserId<long>(),
                UpdatedOn = DateTime.UtcNow,
            };

            Db.tabFloorPlans.Add(floorPlan);

            foreach (var item in fp.TempFloorTables)
            {
                var floorTable = new FloorTable()
                {
                    Angle = item.Angle,
                    CreatedOn = item.CreatedOn,
                    FloorPlanId = floorPlan.FloorPlanId,
                    TableDesign = item.TableDesign,
                    MaxCover = item.MaxCover,
                    MinCover = item.MinCover,
                    TableName = item.TableName,
                    TBottom = item.TBottom,
                    TLeft = item.TLeft,
                    TRight = item.TRight,
                    TTop = item.TTop,
                    UpdatedOn = item.UpdatedOn,
                    HtmlId = item.HtmlId,
                    Shape = item.Shape,
                    Size = item.Size,
                    IsTemporary = false
                };

                Db.tabFloorTables.Add(floorTable);

                //StringBuilder design = new StringBuilder();
                //design.Append(item.TableDesign.Substring(0, item.TableDesign.LastIndexOf("<input")));
                //design.Append("<input id=\"FloorTableId\" name=\"FloorTableId\" type=\"hidden\" value=\"" + floorTable.FloorTableId + "\"/></div>");

                //floorTable.TableDesign = design.ToString();

                //Db.Entry(floorTable).State = EntityState.Modified;
            }

            Db.SaveChanges();

            return RedirectToAction("Index");
        }