Пример #1
0
        private List<string> SetCheckFeature()
        {
            List<string> output = new List<string>();
            using (DbModelRepository<Feature> repository = new DbModelRepository<Feature>(new Feature()))
            {
                IQueryable<Feature> features = repository.GetAll<Feature>();

                foreach (var item in features)
                {
                    output.Add(item.Name);
                }
                return output;
            }
        }
Пример #2
0
        private void SetToCharacteristic<TEntity>(TEntity entity, dynamic dynamic) where TEntity : class, IModel<TEntity>
        {
            using (DbModelRepository<TEntity> repository = new DbModelRepository<TEntity>(entity))
            {
                foreach (var d in dynamic)
                {
                    int id = int.Parse(d.Id.ToString());

                    if (repository.GetEntity<TEntity>(id) == null)
                    {
                        switch (entity)
                        {
                            case Skill s:
                                int idFeat = int.Parse(d.IdFeature.ToString());
                                int? idSpecial = string.IsNullOrEmpty(d.IdSpecialAbility.ToString()) ? null : int.Parse(d.IdSpecialAbility.ToString());
                                repository.Create<TEntity>(entity, entity, d.Name.ToString(), idFeat, idSpecial);
                                break;

                            case Area a:
                                int idCity = int.Parse(d.IdCity.ToString());
                                repository.Create<TEntity>(entity, entity, d.Name.ToString(), idCity);
                                break;

                            case Corporation c:
                                bool isGang = bool.Parse(d.Gang.ToString());
                                repository.CreateCorporation<TEntity>(entity, entity, d.Name.ToString(),isGang);
                                break;

                            case Grade g:
                                // TODO : Faire architecture
                                break;
                            default:
                                repository.Create<TEntity>(entity, entity, d.Name.ToString());
                                break;
                        }
                    }

                }
            }
        }