public async Task <PathMinDisplayed> CreatePath(PathModel path)
        {
            int           mapId  = 0;
            List <string> zones  = new List <string>();
            string        userId = User.Claims.First(c => c.Type == "UserID").Value;
            var           user   = await _userManager.FindByIdAsync(userId);

            TrajetDB trajetDB = new TrajetDB()
            {
                Name               = path.Name,
                Type               = (TypePath)path.Type,
                GroupLevelMax      = path.GroupLevelMax,
                GroupLevelMin      = path.GroupLevelMin,
                CaptureItem        = path.CaptureItem,
                Fk_User            = new Guid(userId),
                MaxPod             = path.MaxPod,
                MonsterQuantityMin = path.MonsterQuantityMin,
                MonsterQuantityMax = path.MonsterQuantityMax,
                LeaderBank         = path.LeaderBank,
                IsCapture          = path.IsCapture,
                ListRessource      = path.ListRessource,
                Key = Guid.NewGuid()
            };

            foreach (var monstreLevel in path.MonsterLevel)
            {
                if (trajetDB.MonsterLevel == null)
                {
                    trajetDB.MonsterLevel = new List <SpecificMonsterLevel>();
                }

                trajetDB.MonsterLevel.Add(new SpecificMonsterLevel()
                {
                    MonsterId       = monstreLevel.MonsterId,
                    MonsterLevelMax = monstreLevel.MonsterLevelmax,
                    MonsterLevelMin = monstreLevel.MonsterLevelMin
                });
            }
            foreach (var monstreQuantity in path.MonsterQuantity)
            {
                if (trajetDB.MonsterQuantity == null)
                {
                    trajetDB.MonsterQuantity = new List <SpecificMonsterQuantity>();
                }
                trajetDB.MonsterQuantity.Add(new SpecificMonsterQuantity()
                {
                    MonsterId          = monstreQuantity.MonsterId,
                    MonsterQuantityMax = monstreQuantity.MonsterQuantityMax,
                    MontserQuantityMin = monstreQuantity.MonsterQuantityMin
                });
            }
            foreach (var monstreCapture in path.MonsterCapture)
            {
                if (trajetDB.MonsterCapture == null)
                {
                    trajetDB.MonsterCapture = new List <CaptureMonsterQuantity>();
                }
                trajetDB.MonsterCapture.Add(new CaptureMonsterQuantity()
                {
                    MonsterId       = monstreCapture.MonsterId,
                    MonsterQuantity = monstreCapture.MonsterQuantity
                });
            }
            /* actions du trajet */
            trajetDB.PathAction = new List <PathAction>();
            foreach (PathActionModel action in path.PathAction)
            {
                PathAction pathActionToCreate = new PathAction();
                if (!ListBank.Contains(action.MapPos))
                {
                    MapDB map = Database.Maps.Find(o => o.Coordinate == ("[" + action.MapPos.Replace(';', ',') + "]")).First();

                    mapId = map.Key;
                    if (!zones.Contains(map.AreaName))
                    {
                        zones.Add(map.AreaName);
                    }

                    pathActionToCreate.MapId = mapId;
                    foreach (MapActionModel item in action.Actions)
                    {
                        if (pathActionToCreate.Actions == null)
                        {
                            pathActionToCreate.Actions = new List <MapAction>();
                        }

                        if (item.FightAction != null)
                        {
                            FightAction fightActionToCreate = new FightAction()
                            {
                                Order   = item.Order,
                                IsAlone = item.FightAction.IsAlone
                            };
                            pathActionToCreate.Actions.Add(fightActionToCreate);
                        }
                        else if (item.GatherAction != null)
                        {
                            GatherAction GatherActionToCreate = new GatherAction()
                            {
                                Order = item.Order
                            };
                            pathActionToCreate.Actions.Add(GatherActionToCreate);
                        }
                        else if (item.InteractionAction != null)
                        {
                            InteractionAction InteractionActionToCreate = new InteractionAction()
                            {
                                Order = item.Order,
                                InteractiveIdObject   = item.InteractionAction.InteractiveidObject,
                                InteractiveIdResponse = item.InteractionAction.InteractiveIdResponse,
                                ToBackBank            = item.InteractionAction.ToBackBank,
                                ToGoBank = item.InteractionAction.ToGoBank
                            };
                            pathActionToCreate.Actions.Add(InteractionActionToCreate);
                        }
                        else if (item.moveAction != null)
                        {
                            MoveAction MoveActionToCreate = new MoveAction()
                            {
                                Order      = item.Order,
                                ToBackBank = item.moveAction.ToBackBank,
                                ToGoBank   = item.moveAction.ToGoBank,
                                CellId     = item.moveAction.Cellid
                            };
                            if (item.moveAction.Direction != null)
                            {
                                foreach (string direc in item.moveAction.Direction)
                                {
                                    if (MoveActionToCreate.Direction == null)
                                    {
                                        MoveActionToCreate.Direction = new List <MovementDirectionEnum>();
                                    }
                                    MoveActionToCreate.Direction.Add((MovementDirectionEnum)System.Enum.Parse(typeof(MovementDirectionEnum), direc.ToUpper()));
                                }
                            }
                            pathActionToCreate.Actions.Add(MoveActionToCreate);
                        }
                        else if (item.UseItemAction != null)
                        {
                            UseItemAction UseItemActionToCreate = new UseItemAction()
                            {
                                Order      = item.Order,
                                ItemId     = item.UseItemAction.ItemId,
                                ToBackBank = item.UseItemAction.ToBackBank,
                                ToGoBank   = item.UseItemAction.ToGoBank
                            };
                            pathActionToCreate.Actions.Add(UseItemActionToCreate);
                        }
                        else if (item.ZaapAction != null)
                        {
                            int zaapDestination = Database.Maps.Find(o => o.Coordinate == ("[" + action.MapPos.Replace(';', ',') + "]")).First().Key;

                            ZaapAction UseItemActionctionToCreate = new ZaapAction()
                            {
                                Order       = item.Order,
                                Destination = zaapDestination,
                                ZaapId      = item.ZaapAction.ZaapId,
                                ToBackBank  = item.ZaapAction.ToBackBank,
                                ToGoBank    = item.ZaapAction.ToGoBank
                            };
                            pathActionToCreate.Actions.Add(UseItemActionctionToCreate);
                        }
                        else if (item.ZaapiAction != null)
                        {
                            int        zaapiDestination           = Database.Maps.Find(o => o.Coordinate == ("[" + action.MapPos.Replace(';', ',') + "]")).First().Key;
                            ZaapAction UseItemActionctionToCreate = new ZaapAction()
                            {
                                Order       = item.Order,
                                Destination = zaapiDestination,
                                ZaapId      = item.ZaapiAction.ZaapiId,
                                ToBackBank  = item.ZaapiAction.ToBackBank,
                                ToGoBank    = item.ZaapiAction.ToGoBank
                            };
                            pathActionToCreate.Actions.Add(UseItemActionctionToCreate);
                        }
                    }
                    trajetDB.PathAction.Add(pathActionToCreate);
                }
                else
                {
                    foreach (MapActionModel item in action.Actions)
                    {
                        pathActionToCreate = new PathAction();
                        if (item.moveAction != null)
                        {
                            mapId = item.moveAction.MapId.Value;
                            pathActionToCreate.MapId = mapId;
                            MoveAction MoveActionToCreate = new MoveAction()
                            {
                                Order      = item.Order,
                                ToBackBank = item.moveAction.ToBackBank,
                                ToGoBank   = item.moveAction.ToGoBank,
                                CellId     = item.moveAction.Cellid,
                                MapId      = mapId
                            };
                            if (item.moveAction.Direction != null)
                            {
                                foreach (string direc in item.moveAction.Direction)
                                {
                                    if (MoveActionToCreate.Direction == null)
                                    {
                                        MoveActionToCreate.Direction = new List <MovementDirectionEnum>();
                                    }
                                    MoveActionToCreate.Direction.Add((MovementDirectionEnum)System.Enum.Parse(typeof(MovementDirectionEnum), direc.ToUpper()));
                                }
                            }

                            if (trajetDB.PathAction.Exists(o => o.MapId == mapId))
                            {
                                trajetDB.PathAction.Find(o => o.MapId == mapId).Actions.Add(MoveActionToCreate);
                            }
                            else
                            {
                                pathActionToCreate.Actions = new List <MapAction>();
                                pathActionToCreate.Actions.Add(MoveActionToCreate);
                                trajetDB.PathAction.Add(pathActionToCreate);
                            }
                        }
                        else if (item.BankAction != null)
                        {
                            mapId = item.BankAction.MapId.Value;
                            pathActionToCreate.MapId = mapId;
                            BankAction BankActionToCreate = new BankAction()
                            {
                                MapId = mapId,
                                Order = item.Order
                            };
                            if (trajetDB.PathAction.Exists(o => o.MapId == mapId))
                            {
                                trajetDB.PathAction.Find(o => o.MapId == mapId).Actions.Add(BankActionToCreate);
                            }
                            else
                            {
                                pathActionToCreate.Actions = new List <MapAction>();
                                pathActionToCreate.Actions.Add(BankActionToCreate);
                                trajetDB.PathAction.Add(pathActionToCreate);
                            }
                        }
                    }
                }
            }
            trajetDB.Zones = zones;
            PathMinDisplayed retourPath = new PathMinDisplayed()
            {
                IsCapture  = trajetDB.IsCapture,
                Key        = trajetDB.Key,
                Name       = trajetDB.Name,
                Type       = trajetDB.Type,
                UsedNumber = 0,
                Zones      = trajetDB.Zones
            };

            await Database.Paths.InsertOneAsync(trajetDB);

            return(retourPath);
        }
        public HfDoesInteraction(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "doer_hfid": Doer = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "target_hfid": Target = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "interaction": Interaction = property.Value; break;

                case "doer": if (Doer == null)
                    {
                        Doer = world.GetHistoricalFigure(Convert.ToInt32(property.Value));
                    }
                    else
                    {
                        property.Known = true;
                    } break;

                case "target": if (Target == null)
                    {
                        Target = world.GetHistoricalFigure(Convert.ToInt32(property.Value));
                    }
                    else
                    {
                        property.Known = true;
                    } break;

                case "interaction_action": InteractionAction = property.Value.Replace("[IS_HIST_STRING_1:", "").Replace("[IS_HIST_STRING_2:", "").Replace("]", ""); break;

                case "interaction_string": InteractionString = property.Value.Replace("[IS_HIST_STRING_2:", "").Replace("[I_TARGET:A:CREATURE", "").Replace("]", ""); break;

                case "source": Source = property.Value; break;

                case "region": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "site": Site = world.GetSite(Convert.ToInt32(property.Value)); break;
                }
            }

            if (Target != null)
            {
                string creatureType = "";
                if (!string.IsNullOrWhiteSpace(Interaction))
                {
                    if (!Target.ActiveInteractions.Contains(Interaction))
                    {
                        Target.ActiveInteractions.Add(Interaction);
                    }
                    if (Doer != null)
                    {
                        Doer.LineageCurseChilds.Add(Target);
                        Target.LineageCurseParent = Doer;
                    }

                    if (Interaction.Contains("VAMPIRE"))
                    {
                        creatureType = "vampire";
                    }
                    if (Interaction.Contains("WEREBEAST"))
                    {
                        creatureType = "werebeast";
                    }
                    if (Interaction.Contains("SECRET"))
                    {
                        creatureType = "necromancer";
                    }
                    if (Interaction.Contains("ANIMATE"))
                    {
                        creatureType = "animated corpse";
                    }
                    if (Interaction.Contains("UNDEAD_RES"))
                    {
                        creatureType = "resurrected undead";
                    }
                }
                if (!string.IsNullOrWhiteSpace(InteractionAction) && InteractionAction.Contains(", passing on the "))
                {
                    Target.Interaction = InteractionAction.Replace(", passing on the ", "");
                    if (!string.IsNullOrEmpty(Target.Interaction))
                    {
                        creatureType = "were" + Target.Interaction.Replace(" monster curse", " ");
                    }
                }
                else if (!string.IsNullOrWhiteSpace(InteractionString) && InteractionString.Contains(" to assume the form of a "))
                {
                    Target.Interaction = InteractionString.Replace(" to assume the form of a ", "").Replace("-like", "").Replace(" every full moon", " curse");
                    if (!string.IsNullOrEmpty(Target.Interaction))
                    {
                        creatureType = "were" + Target.Interaction.Replace(" monster curse", " ");
                    }
                }

                if (!string.IsNullOrEmpty(creatureType))
                {
                    Target.CreatureTypes.Add(new HistoricalFigure.CreatureType(creatureType, this));
                }
            }
            Doer.AddEvent(this);
            Target.AddEvent(this);
            Region.AddEvent(this);
            Site.AddEvent(this);
        }
        public HfDoesInteraction(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "doer_hfid": Doer = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "target_hfid": Target = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "interaction": Interaction = property.Value; break;

                case "doer": if (Doer == null)
                    {
                        Doer = world.GetHistoricalFigure(Convert.ToInt32(property.Value));
                    }
                    else
                    {
                        property.Known = true;
                    } break;

                case "target": if (Target == null)
                    {
                        Target = world.GetHistoricalFigure(Convert.ToInt32(property.Value));
                    }
                    else
                    {
                        property.Known = true;
                    } break;

                case "interaction_action": InteractionAction = property.Value.Replace("[IS_HIST_STRING_1:", "").Replace("[IS_HIST_STRING_2:", "").Replace("]", ""); break;

                case "interaction_string": InteractionString = property.Value.Replace("[IS_HIST_STRING_2:", "").Replace("[I_TARGET:A:CREATURE", "").Replace("]", ""); break;

                case "source": Source = property.Value; break;

                case "region": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "site": Site = world.GetSite(Convert.ToInt32(property.Value)); break;
                }
            }

            if (Target != null && !string.IsNullOrWhiteSpace(Interaction))
            {
                if (!Target.ActiveInteractions.Contains(Interaction))
                {
                    Target.ActiveInteractions.Add(Interaction);
                }
                if (Doer != null)
                {
                    Doer.LineageCurseChilds.Add(Target);
                    Target.LineageCurseParent = Doer;
                }
            }
            if (Target != null && !string.IsNullOrWhiteSpace(InteractionAction))
            {
                if (InteractionAction.Contains(", passing on the "))
                {
                    Target.Interaction = InteractionAction.Replace(", passing on the ", "");
                }
                else if (InteractionString.Contains(" to assume the form of a "))
                {
                    Target.Interaction = InteractionString.Replace(" to assume the form of a ", "").Replace("-like", "").Replace(" every full moon", " curse");
                }
            }
            Doer.AddEvent(this);
            Target.AddEvent(this);
            Region.AddEvent(this);
            Site.AddEvent(this);
        }