public ActionResult BlockInsert(BlocksModel blocksModel, int[] floorsList)
        {
            Blocks block = blocksModel.ModelToEnity(true);

            block.IsActive = true;
            _serviceBlocks.Insert(block);
            for (int i = 0; i < floorsList.Length; i++)
            {
                BlockFloors blockFloors = new BlockFloors();
                blockFloors.BlockId = block.Id;
                blockFloors.FloorId = floorsList[i];
                _serviceBlockFloors.Insert(blockFloors);
            }
            return(RedirectToAction("BlockList"));
        }
        public ActionResult BlockEdit(int id, int[] floorsList)
        {
            Blocks block     = _serviceBlocks.GetById(id);
            var    allFloors = _servisceFloors.GetAll().Where(s => s.IsActive);

            foreach (var item in allFloors)
            {
                BlockFloors bf = _serviceBlockFloors.GetAll().Where(s => s.BlockId == block.Id && s.FloorId == item.Id).FirstOrDefault();
                if (bf != null)
                {
                    _serviceBlockFloors.Delete(bf);
                }
            }

            for (int i = 0; i < floorsList.Length; i++)
            {
                BlockFloors blockFloors = new BlockFloors();
                blockFloors.BlockId = block.Id;
                blockFloors.FloorId = floorsList[i];
                _serviceBlockFloors.Insert(blockFloors);
            }
            return(RedirectToAction("BlockList"));
        }
        public ActionResult BlockEdit(int id, int[] floorsList)
        {
            Blocks block = _serviceBlocks.GetById(id);
            var allFloors = _servisceFloors.GetAll().Where(s => s.IsActive);
            foreach (var item in allFloors)
            {
                BlockFloors bf = _serviceBlockFloors.GetAll().Where(s => s.BlockId == block.Id && s.FloorId == item.Id).FirstOrDefault();
                if (bf != null)
                {
                    _serviceBlockFloors.Delete(bf);
                }
            }

            for (int i = 0; i < floorsList.Length; i++)
            {
                BlockFloors blockFloors = new BlockFloors();
                blockFloors.BlockId = block.Id;
                blockFloors.FloorId = floorsList[i];
                _serviceBlockFloors.Insert(blockFloors);
            }
            return RedirectToAction("BlockList");
        }
 public ActionResult BlockInsert(BlocksModel blocksModel, int[] floorsList)
 {
     Blocks block = blocksModel.ModelToEnity(true);
     block.IsActive = true;
     _serviceBlocks.Insert(block);
     for (int i = 0; i < floorsList.Length; i++)
     {
         BlockFloors blockFloors = new BlockFloors();
         blockFloors.BlockId = block.Id;
         blockFloors.FloorId = floorsList[i];
         _serviceBlockFloors.Insert(blockFloors);
     }
     return RedirectToAction("BlockList");
 }