示例#1
0
        public IMongoCollection <T> Collection <T>() where T : MongoEntity
        {
            //Pluralize class name
            string tableName = PluralizeDocumentName ? PluralizationProvider.Pluralize(typeof(T).Name) : typeof(T).Name;

            return(database.GetCollection <T>(tableName));
        }
示例#2
0
        /// <summary>
        /// Returns table name for the specified entity type
        /// </summary>
        /// <param name="entityType"></param>
        /// <returns></returns>
        public static string GetTableName(Type entityType)
        {
            if (IsRootEntity(entityType))
            {
                // If the `TableAttribute` exists - use it. Note: we search the attribute in base classes too, it allows to use it in the abstract classes
                var tableAttribute = entityType.Closest(t => t.BaseType, t => t.HasAttribute <TableAttribute>())?.GetAttribute <TableAttribute>();
                if (tableAttribute != null)
                {
                    return(tableAttribute.Name);
                }

                var name   = PluralizationProvider.Pluralize(entityType.Name);
                var prefix = GetTablePrefix(entityType);
                if (!string.IsNullOrWhiteSpace(prefix))
                {
                    name = $"{prefix}{name}";
                }

                return(name);
            }
            else
            {
                return(GetTableName(GetRootEntity(entityType)));
            }
        }
示例#3
0
        public void Drop <T>() where T : MongoEntity
        {
            //Pluralize class name
            string tableName = PluralizeDocumentName ? PluralizationProvider.Pluralize(typeof(T).Name) : typeof(T).Name;

            database.DropCollection(tableName);
        }
        public void ShouldPluralizeWord(string word, string expected)
        {
            // Arrange
            string actual = PluralizationProvider.Pluralize(word);

            // Assert
            Assert.Equal(expected, actual);
        }
        public void Apply(ControllerModel controller)
        {
            if (controller.ControllerType.GetGenericTypeDefinition() != typeof(GenericController <>))
            {
                return;
            }
            var entityType = controller.ControllerType.GenericTypeArguments[0];

            controller.ControllerName = PluralizationProvider.Pluralize(entityType.Name);
        }
示例#6
0
        public void DoesNotCreateProductsWhenThereAreNotProducts()
        {
            var result = Product.Create(new List <Product.Dto>().AsReadOnly());

            result.IsFail.Should().BeTrue();
            result.IfFail(validationError =>
            {
                validationError.First().FieldId.Should().Be(PluralizationProvider.Pluralize(nameof(Product)));
                validationError.First().ErrorCode.Should().Be(GenericValidationErrorCode.Required);
            });
        }
示例#7
0
 public void CreateCollection(params string[] names)
 {
     if (names is null)
     {
         return;
     }
     foreach (var name in names)
     {
         MongoService.CreateCollectionAsync(
             PluralizationProvider.Pluralize(name));
     }
 }
示例#8
0
        /// <summary>
        /// Generates C# code file containig delete command for the specified entity
        /// </summary>
        /// <param name="entity">entity type</param>
        private static void GenerateDeleteCommand(Type entity)
        {
            string fileName = GetGenerationFilePath("Commands", "Delete", entity.Name);
            string template = File.ReadAllText("DeleteCommandTemplate.txt");

            // adding default namespaces
            List <string> namespaces = new List <string>();

            namespaces.Add("using System;");
            namespaces.Add("using MediatR;");
            namespaces.Add("using System.Threading;");
            namespaces.Add("using System.Threading.Tasks;");
            namespaces.Add($"using {dbContext_interface_namespace};");
            namespaces.Add($"using {exceptions_namespace};");
            namespaces.Add($"using {entities_namespace};");

            template = template.Replace("<#codeGenerateion_namespace#>", codeGenerateion_namespace);
            template = template.Replace("<#dbContext_interface#>", dbContext_interface);

            string className = $"Delete{entity.Name}Command";

            template = template.Replace("<#ClassName#>", className);

            template = template.Replace("<#Entity#>", entity.Name);
            string entitySet = PluralizationProvider.Pluralize(entity.Name);

            template = template.Replace("<#EntitySet#>", entitySet);

            var key = FindKeyPropertyForEntity(entity);

            // generating properties
            StringBuilder sb_definitions = new StringBuilder();

            // declare the property for command request
            string p_type = GetTypeToDecalre(key.PropertyType, namespaces);

            sb_definitions.Append($"public {p_type} {key.Name} {{ set; get; }}");
            sb_definitions.Append(Environment.NewLine + "\t\t");


            // writing namespaces
            template = template.Replace("<#namespaces#>", string.Join(Environment.NewLine, namespaces));

            // writing properties
            template = template.Replace("<#Properties#>", sb_definitions.ToString());

            // writing generated code inside the file
            File.WriteAllText(fileName, template);
        }
示例#9
0
        /// <summary>
        /// Generates a string path to place the code file.
        /// </summary>
        /// <param name="mode">Command or Query</param>
        /// <param name="operation">Create, Delete, Update, Select</param>
        /// <param name="entity">entity type</param>
        /// <param name="isValidator">wether it is for generating the command validator or not</param>
        /// <returns></returns>
        private static string GetGenerationFilePath(string mode, string operation, string entity, bool isValidator = false)
        {
            string entitySet         = PluralizationProvider.Pluralize(entity);
            string solutionDirectory = Directory.GetCurrentDirectory().Substring(0, Directory.GetCurrentDirectory().IndexOf("CQRSGenerator"));
            string dir = Path.Combine(solutionDirectory, codeGenerateion_path, entitySet, mode, operation + entity);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string modDir   = mode == "Commands" ? "Commmand" : "Query";
            string fileName = $"{operation}{entity}{modDir}";

            fileName += isValidator ? "Validator.cs" : ".cs";
            return(Path.Combine(dir, fileName));
        }
示例#10
0
        protected override IMongoCollection <T> Context <T>(bool IsExtendEntity = false)
        {
            Type _type = typeof(T);

            if (_type == typeof(T1))
            {
                return((IMongoCollection <T>)Context1);
            }
            else
            {
                return(IsExtendEntity ? ExtendEntity()
            : throw GetException(_type));
            }

            IMongoCollection <T> ExtendEntity()
            {
                context.CreateCollection(_type.Name);
                return(context.MongoService.GetCollection <T>(PluralizationProvider.Pluralize(_type.Name)));
            }
        }
示例#11
0
        public AccountRepository(JolijoberDbContext context,
                                 UserManager <AccountUser> userManager, SignInManager <AccountUser> signInManager, RoleManager <AccountRole> roleManager,
                                 JolijoberService contextmongodb) : base(context)
        {
            UserManager   = userManager;
            SignInManager = signInManager;
            RoleManager   = roleManager;


            this.contextmongodb = contextmongodb.MongoService.GetCollection <Identity>(PluralizationProvider.Pluralize(nameof(Identity)));
        }
示例#12
0
 internal static string MakePlural(this string str)
 {
     return(PluralizationProvider.Pluralize(str));
 }
示例#13
0
            IReadOnlyList <Product> > Create(IReadOnlyList <Dto> productsDto)
        {
            if (productsDto.Count == 0)
            {
                return(new ValidationError <GenericValidationErrorCode>(
                           fieldId: PluralizationProvider.Pluralize(nameof(Product)),
                           errorCode: GenericValidationErrorCode.Required));
            }

            var validationErrors = new Seq <ValidationError <GenericValidationErrorCode> >();
            var products         = new List <Product>();

            productsDto
            .Select((productDto, index) => new { Value = productDto, Index = index })
            .ToList()
            .ForEach(productDto =>
            {
                var link  = Link.Create(productDto.Value.Link);
                var units = Units.Create(productDto.Value.Units);
                var additionalInformation = productDto.Value.AdditionalInformation
                                            .Map(x => ValueObjects.AdditionalInformation.Create(x));
                var promotionCode = productDto.Value.PromotionCode
                                    .Map(x => ValueObjects.PromotionCode.Create(x));

                if (link.IsFail ||
                    units.IsFail ||
                    additionalInformation.Match(None: () => false, Some: x => x.IsFail) ||
                    promotionCode.Match(None: () => false, Some: x => x.IsFail))
                {
                    link.IfFail(errors => validationErrors  = validationErrors.Concat(MapLinkValidationErrors(errors, productDto.Index)));
                    units.IfFail(errors => validationErrors = validationErrors.Concat(MapUnitsValidationErrors(errors, productDto.Index)));
                    additionalInformation.IfSome(result =>
                                                 result.IfFail(errors => validationErrors = validationErrors.Concat(MapAdditionalInformationValidationErrors(errors, productDto.Index))));
                    promotionCode.IfSome(result =>
                                         result.IfFail(errors => validationErrors = validationErrors.Concat(MapPromotionCodeValidationErrors(errors, productDto.Index))));
                }
                else
                {
                    var product = new Product(
                        id: Id.Create(),
                        link: link.IfFail(() => throw new InvalidOperationException()),
                        units: units.IfFail(() => throw new InvalidOperationException()),
                        additionalInformation: additionalInformation.Match(
                            None: () => null,
                            Some: x => x.IfFail(() => throw new InvalidOperationException())),
                        promotionCode: promotionCode.Match(
                            None: () => null,
                            Some: x => x.IfFail(() => throw new InvalidOperationException())));
                    products.Add(product);
                }
            });

            if (validationErrors.Count > 0)
            {
                return(validationErrors);
            }
            return(products.ToList().AsReadOnly());

            Seq <ValidationError <GenericValidationErrorCode> > MapLinkValidationErrors(
                Seq <ValidationError <GenericValidationErrorCode> > validationErrors,
                int index)
            {
                return(validationErrors.Map(validationError => new ValidationError <GenericValidationErrorCode>(
                                                fieldId: $"{nameof(Product)}[{index}].{nameof(Link)}",
                                                errorCode: validationError.ErrorCode)));
            }

            Seq <ValidationError <GenericValidationErrorCode> > MapUnitsValidationErrors(
                Seq <ValidationError <GenericValidationErrorCode> > validationErrors,
                int index)
            {
                return(validationErrors.Map(validationError => new ValidationError <GenericValidationErrorCode>(
                                                fieldId: $"{nameof(Product)}[{index}].{nameof(Units)}",
                                                errorCode: validationError.ErrorCode)));
            }

            Seq <ValidationError <GenericValidationErrorCode> > MapAdditionalInformationValidationErrors(
                Seq <ValidationError <GenericValidationErrorCode> > validationErrors,
                int index)
            {
                return(validationErrors.Map(validationError => new ValidationError <GenericValidationErrorCode>(
                                                fieldId: $"{nameof(Product)}[{index}].{nameof(AdditionalInformation)}",
                                                errorCode: validationError.ErrorCode)));
            }

            Seq <ValidationError <GenericValidationErrorCode> > MapPromotionCodeValidationErrors(
                Seq <ValidationError <GenericValidationErrorCode> > validationErrors,
                int index)
            {
                return(validationErrors.Map(validationError => new ValidationError <GenericValidationErrorCode>(
                                                fieldId: $"{nameof(Product)}[{index}].{nameof(PromotionCode)}",
                                                errorCode: validationError.ErrorCode)));
            }
        }
示例#14
0
 protected JolijoberRepository(JolijoberService context)
 {
     Context = context.MongoService.GetCollection <T>(PluralizationProvider.Pluralize(typeof(T).Name));
 }
示例#15
0
        /// <summary>
        /// Generates C# code file containig update command for the specified entity
        /// </summary>
        /// <param name="entity">entity type</param>
        private static void GenerateUpdateCommand(Type entity)
        {
            string fileName = GetGenerationFilePath("Commands", "Update", entity.Name);
            string template = File.ReadAllText("UpdateCommandTemplate.txt");

            // adding default namespaces
            List <string> namespaces = new List <string>();

            namespaces.Add("using System;");
            namespaces.Add("using System.Collections.Generic;");
            namespaces.Add("using MediatR;");
            namespaces.Add("using System.Threading;");
            namespaces.Add("using System.Threading.Tasks;");
            namespaces.Add($"using {dbContext_interface_namespace};");
            namespaces.Add($"using {exceptions_namespace};");
            namespaces.Add($"using {entities_namespace};");

            template = template.Replace("<#codeGenerateion_namespace#>", codeGenerateion_namespace);
            template = template.Replace("<#dbContext_interface#>", dbContext_interface);

            string className = $"Update{entity.Name}Command";

            template = template.Replace("<#ClassName#>", className);

            template = template.Replace("<#Entity#>", entity.Name);
            string entitySet = PluralizationProvider.Pluralize(entity.Name);

            template = template.Replace("<#EntitySet#>", entitySet);

            // generating properties
            StringBuilder sb_definitions = new StringBuilder();
            StringBuilder sb_assigments  = new StringBuilder();

            foreach (var p in entity.GetProperties().Where(x => x.CanWrite && x.CanRead && x.MemberType == MemberTypes.Property))
            {
                // exclude this property if it's in the general exclution list or in the specific list for current entity
                if (excluded_properties_update.Contains(p.Name) ||
                    (excluded_properties_update_mapping.ContainsKey(entity.Name) &&
                     excluded_properties_update_mapping.GetValueOrDefault(entity.Name).Contains(p.Name)))
                {
                    continue;
                }

                // declare the property for command request
                string p_type = GetTypeToDecalre(p.PropertyType, namespaces);
                sb_definitions.Append($"public {p_type} {p.Name} {{ set; get; }}");
                sb_definitions.Append(Environment.NewLine + "\t\t");

                // assign request properties to the entity
                sb_assigments.Append($"entity.{p.Name} = request.{p.Name};");
                sb_assigments.Append(Environment.NewLine + "\t\t\t\t");
            }

            // writing namespaces
            template = template.Replace("<#namespaces#>", string.Join(Environment.NewLine, namespaces));

            // writing properties
            template = template.Replace("<#Properties#>", sb_definitions.ToString());

            // writing assigments inside command handler
            template = template.Replace("<#PropertiesAssigments#>", sb_assigments.ToString());

            // writing generated code inside the file
            File.WriteAllText(fileName, template);
        }
示例#16
0
        /// <summary>
        /// Generates C# code file containig create validator command for the specified entity
        /// </summary>
        /// <param name="entity">entity type</param>
        private static void GenerateUpdateCommandValidator(Type entity)
        {
            string fileName = GetGenerationFilePath("Commands", "Update", entity.Name, true);
            string template = File.ReadAllText("UpdateCommandValidatorTemplate.txt");

            template = template.Replace("<#codeGenerateion_namespace#>", codeGenerateion_namespace);

            string className = $"Update{entity.Name}Command";

            template = template.Replace("<#ClassName#>", className);

            template = template.Replace("<#Entity#>", entity.Name);
            string entitySet = PluralizationProvider.Pluralize(entity.Name);

            template = template.Replace("<#EntitySet#>", entitySet);

            // generating properties
            StringBuilder sb_rules = new StringBuilder();

            var annotations                    = dbContext.Model.FindEntityType(entity).GetAnnotations();
            var CheckConstraints               = dbContext.Model.FindEntityType(entity).GetCheckConstraints();
            var DeclaredForeignKeys            = dbContext.Model.FindEntityType(entity).GetDeclaredForeignKeys();
            var DeclaredNavigations            = dbContext.Model.FindEntityType(entity).GetDeclaredNavigations();
            var DeclaredProperties             = dbContext.Model.FindEntityType(entity).GetDeclaredProperties();
            var DeclaredReferencingForeignKeys = dbContext.Model.FindEntityType(entity).GetDeclaredReferencingForeignKeys();

            foreach (var p in dbContext.Model.FindEntityType(entity).GetDeclaredProperties().Where(x => x.ValueGenerated == Microsoft.EntityFrameworkCore.Metadata.ValueGenerated.Never))
            {
                // exclude this property if it's in the general exclution list or in the specific list for current entity
                if (excluded_properties_update.Contains(p.Name) ||
                    (excluded_properties_update_mapping.ContainsKey(entity.Name) &&
                     excluded_properties_update_mapping.GetValueOrDefault(entity.Name).Contains(p.Name)))
                {
                    continue;
                }

                // declare rules for the property
                List <string> rules = new List <string>();

                // check if it's required. exclude types that are not null by default and have a default value like int
                if (!p.IsNullable && !p.ClrType.IsValueType)
                {
                    if (p.ClrType == typeof(string))
                    {
                        rules.Add(".NotEmpty()");
                    }
                    else
                    {
                        rules.Add(".NotNull()");
                    }
                }

                // check if it has a fixed length
                if (p.IsFixedLength())
                {
                    rules.Add($".Length({p.GetMaxLength()})");
                }
                else if (p.GetMaxLength().HasValue) // check if it has a max length
                {
                    rules.Add($".MaximumLength({p.GetMaxLength()})");
                }

                if (rules.Count > 0)
                {
                    sb_rules.Append($"RuleFor(v => v.{p.Name})" + Environment.NewLine + "\t\t\t\t");
                    sb_rules.Append(string.Join(Environment.NewLine + "\t\t\t\t", rules));
                    sb_rules.Append(";");
                    sb_rules.Append(Environment.NewLine + "\t\t\t");
                }
            }

            template = template.Replace("<#rules#>", sb_rules.ToString());

            // writing generated code inside the file
            File.WriteAllText(fileName, template);
        }
示例#17
0
 protected MongoDBRepository(MongoDBService context)
 {
     this.context = context;
     Context1     = context.MongoService.GetCollection <T1>(PluralizationProvider.Pluralize(typeof(T1).Name));
 }
示例#18
0
 public static string Pluralize(this string value)
 {
     return(PluralizationProvider.Pluralize(value));
 }
示例#19
0
        public static async Task InitializeAsync(IServiceProvider services)
        {
            var context = (JolijoberService)services.GetService(typeof(JolijoberService));

            var  ContextPost = context.MongoService.GetCollection <Post>(PluralizationProvider.Pluralize(typeof(Post).Name));
            long count       = await ContextPost.CountAsync(x => true);


            IEnumerable <Post> ranposts = Enumerable.Range(0, 12).Select(x => new Post()
            {
                Date           = DateTime.Now,
                Title          = titels[random.Next(0, titels.Length - 1)],
                Sallaries      = new MinMax(82, 40),
                Availabilty    = Availabilties.PartTime,
                Descreption    = dess[random.Next(0, dess.Length - 1)],
                Tags           = new[] { "Java", "Android" },
                Specifications = new[] { "شركة برمجية" },
                Region         = "سوريا-العالم",
                Likes          = new Like[] { new Like()
                                              {
                                                  Liker = "مرا من هنا لايك", LikerId = "asd8489"
                                              } },
                Comments = new Comment[] {
                    new Comment()
                    {
                        CommenterId = "asd8489", Commenter = names[random.Next(0, names.Length - 1)], Date = DateTime.Now, Text = "سوف اقوم بالمراسلة",
                    },
                },
                Views       = 0,
                AccountId   = "86545112",
                AccountName = names[random.Next(0, names.Length - 1)],
                AccountType = AccountTypes.User,
                PostType    = PostTypes.Job
            });



            IEnumerable <Post> posts = new List <Post>()
            {
                new Post()
                {
                    Date           = DateTime.Now,
                    Title          = "مطور تطبيقات ويب",
                    Sallaries      = new MinMax(600, 800),
                    Availabilty    = Availabilties.FullTime,
                    Descreption    = "خبرة في مجال الويب شغف يعمل بجد يحتاج لإتمام إطارين عمل على الاقل يفضل ان يكون خريج والخبرة جيدة في الدوت نت",
                    Tags           = new[] { "C#", "dotNet" },
                    Specifications = new[] { "مطور ويب كامل" },
                    Region         = "سوريا-حلب",
                    //Likes= new Like[]{ },
                    //Comments= new Comment[]{ },
                    Views       = 0,
                    AccountId   = "894545456",
                    AccountName = "طيب الطيب",
                    AccountType = AccountTypes.User,
                    PostType    = PostTypes.Job
                },

                new Post()
                {
                    Date           = DateTime.Now,
                    Title          = "مطور تطبيقات اندرويد",
                    Sallaries      = new MinMax(200, 400),
                    Availabilty    = Availabilties.PartTime,
                    Descreption    = "خبير في تطبيقات الاتدرويد يتقن استخلاص واجهات جميلة",
                    Tags           = new[] { "Java", "Android" },
                    Specifications = new[] { "مطور تطبيقات اندرويد" },
                    Region         = "سوريا-دمشق",
                    Likes          = new Like[] { new Like()
                                                  {
                                                      Liker = "طيب الطيب", LikerId = "asd8489"
                                                  } },
                    Comments = new Comment[] {
                        new Comment()
                        {
                            CommenterId = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "asdad",
                        },
                        new Comment()
                        {
                            CommenterId   = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "asdad",
                            ChildComments = new Comment[] { new Comment()
                                                            {
                                                                CommenterId   = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "asdad",
                                                                ChildComments = new Comment[] {
                                                                    new Comment()
                                                                    {
                                                                        CommenterId = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "asdad"
                                                                    },
                                                                    new Comment()
                                                                    {
                                                                        CommenterId = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "asdad",
                                                                    }
                                                                }
                                                            }, new Comment()
                                                            {
                                                                CommenterId = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "asdad",
                                                            } }
                        }
                        , new Comment()
                        {
                            CommenterId = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "asdad",
                        },
                    },
                    Views       = 0,
                    AccountId   = "86545112",
                    AccountName = "محمد حذيفة أصيل",
                    AccountType = AccountTypes.User,
                    PostType    = PostTypes.Job
                },



                new Post()
                {
                    Date           = DateTime.Now,
                    Title          = "مطور تطبيقات اندرويد",
                    Sallaries      = new MinMax(200, 400),
                    Availabilty    = Availabilties.PartTime,
                    Descreption    = "خبير في تطبيقات الاتدرويد يتقن استخلاص واجهات جميلة",
                    Tags           = new[] { "Java", "Android" },
                    Specifications = new[] { "مطور تطبيقات اندرويد" },
                    Region         = "سوريا-دمشق",
                    Likes          = new Like[] { new Like()
                                                  {
                                                      Liker = "طيب الطيب", LikerId = "asd8489"
                                                  } },
                    Comments = new Comment[] {
                        new Comment()
                        {
                            CommenterId = "asd8489", Commenter = "شخص ما", Date = DateTime.Now, Text = "سوف اثوم بالمراسلة",
                        },
                    },
                    Views       = 0,
                    AccountId   = "86545112",
                    AccountName = "محمد حذيفة أصيل",
                    AccountType = AccountTypes.User,
                    PostType    = PostTypes.Job
                },



                new Post()
                {
                    Date           = DateTime.Now,
                    Title          = titels[random.Next(0, titels.Length - 1)],
                    Sallaries      = new MinMax(82, 40),
                    Availabilty    = Availabilties.PartTime,
                    Descreption    = dess[random.Next(0, dess.Length - 1)],
                    Tags           = new[] { "Java", "Android" },
                    Specifications = new[] { "شركة برمجية" },
                    Region         = "سوريا-العالم",
                    Likes          = new Like[] { new Like()
                                                  {
                                                      Liker = "مرا من هنا لايك", LikerId = "asd8489"
                                                  } },
                    Comments = new Comment[] {
                        new Comment()
                        {
                            CommenterId = "asd8489", Commenter = "شخص ما", Date = DateTime.Now, Text = "سوف اقوم بالمراسلة",
                        },
                    },
                    Views       = 0,
                    AccountId   = "86545112",
                    AccountName = names[random.Next(0, names.Length - 1)],
                    AccountType = AccountTypes.User,
                    PostType    = PostTypes.Job
                },



                new Post()
                {
                    Date           = DateTime.Now,
                    Title          = "مبرمج تطبيقات جوال",
                    Sallaries      = new MinMax(40, 20),
                    Availabilty    = Availabilties.FullTime,
                    Descreption    = "خبرة في مجال الويب شغف يعمل بجد يحتاج لإتمام إطارين عمل على الاقل يفضل ان يكون خريج والخبرة جيدة في الدوت نت",
                    Tags           = new[] { "C#", "dotNet" },
                    Specifications = new[] { "مطور ويب كامل" },
                    Region         = "سوريا-حلب",
                    //Likes= new Like[]{ },
                    //Comments= new Comment[]{ },
                    Views       = 0,
                    AccountId   = "894545456",
                    AccountName = "طيب الطيب",
                    AccountType = AccountTypes.User,
                    PostType    = PostTypes.Job
                },

                new Post()
                {
                    Date           = DateTime.Now,
                    Title          = "مطور تطبيقات اندرويد",
                    Sallaries      = new MinMax(200, 400),
                    Availabilty    = Availabilties.PartTime,
                    Descreption    = "خبير في تطبيقات الاتدرويد يتقن استخلاص واجهات جميلة",
                    Tags           = new[] { "Java", "Android" },
                    Specifications = new[] { "مطور تطبيقات اندرويد" },
                    Region         = "سوريا-دمشق",
                    Likes          = new Like[] { new Like()
                                                  {
                                                      Liker = "حذيفة أصيل", LikerId = "asd8489"
                                                  } },
                    Comments = new Comment[] {
                        new Comment()
                        {
                            CommenterId = "asd8489", Commenter = "عبد العزيز", Date = DateTime.Now, Text = "الراتب",
                        },
                        new Comment()
                        {
                            CommenterId   = "asd8489", Commenter = "محمد أحمد ", Date = DateTime.Now, Text = "asdad",
                            ChildComments = new Comment[] { new Comment()
                                                            {
                                                                CommenterId   = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "سعر الساعة",
                                                                ChildComments = new Comment[] {
                                                                    new Comment()
                                                                    {
                                                                        CommenterId = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "عمل جيد "
                                                                    },
                                                                }
                                                            }, new Comment()
                                                            {
                                                                CommenterId = "جميل", Commenter = "ام كلثوم", Date = DateTime.Now, Text = "كيف يمكن احصل على ذلك العمل",
                                                            } }
                        }
                        , new Comment()
                        {
                            CommenterId = "asd8489", Commenter = "طيب الطيب", Date = DateTime.Now, Text = "غير واضح",
                        },
                    },
                    Views       = 10,
                    AccountId   = "86545112",
                    AccountName = "محمد حذيفة أصيل",
                    AccountType = AccountTypes.User,
                    PostType    = PostTypes.Job
                },
            };
            //    if (count==0)
            await ContextPost.InsertManyAsync(posts.Concat(ranposts));
        }