Example #1
0
        public void Create_Formula_That_Not_Exist()
        {
            List <FormulaName> formulaNames = CalculationFormulaFactory.GetAll();
            IFormula           formula      = CalculationFormulaFactory.Create(FormulaType.AreaBased);

            Assert.IsNotNull(formula, "formala is created");
        }
Example #2
0
        public void Get_All_Implemented_Formula_Type()
        {
            List <FormulaName> formulaNames    = CalculationFormulaFactory.GetAll();
            List <FormulaName> CreatedFormulas = new List <FormulaName>();

            FormulaName areabased = new  FormulaName(FormulaType.AreaBased, "Asa.ApartmentManagement.Core.ChargeCalculation.Formulas.AreaBaseFormula");

            CreatedFormulas.Add(areabased);
            bool checkExistence = false;

            foreach (var formul in formulaNames)
            {
                checkExistence = formulaNames.Any(item => item.TypeName == formul.TypeName);
                if (checkExistence)
                {
                    break;
                }
            }

            Assert.IsTrue(checkExistence);
        }
Example #3
0
 public IEnumerable <FormulaNameDto> GetAll() => CalculationFormulaFactory.GetAll().Select(x => new FormulaNameDto {
     Title = x.Title, Type = x.TypeName
 });
        static async Task Main(string[] args)
        {
            //autoResetEvent = new AutoResetEvent(false);
            //Console.WriteLine("Hello World!");

            ////Thread myWorker1 = new Thread(() => DoMyFirstJob());
            ////myWorker1Start();

            ////Thread myWorker2 = new Thread(() => DoMySecondJob());
            ////myWorker2.Start();

            //Console.WriteLine($"Main thread id { Thread.CurrentThread.ManagedThreadId} ");

            //var task1 = Task.Run(DoMyFirstJob);
            //var task2 = Task.Run(DoMySecondJob);
            //await Task.WhenAll(task1, task2);

            //var connectionString = ConfigurationManager.ConnectionStrings["AppartmentManagementCNX"].ConnectionString;

            //var baseInfoService = new BaseInfoApplicationService(connectionString);
            //var units = await baseInfoService.GetAllOwnerTenantByUnitId(1);



            #region EF
            IEnumerable <Student> students = null;
            //using (var dbContext = new StudentDbContext())
            //{
            //    students = dbContext.Students.Where(x => x.Name == "Ali").ToList();
            //    /*OK=>  var dateTime = new DateTime(1900, 1, 1);
            //     * students = dbContext.Students.Where(x => x.BirthDate > dateTime).ToList();
            //    */
            //    // OK=> students = dbContext.Students.Where(x => x.BirthDate.Year > 1900).ToList();
            //    //Don't do this => students = dbContext.Students.Where(x=> IsBithYearGraterThan(x.BirthDate.Year,1900)).ToList();
            //}
            //foreach (var item in students)
            //{
            //    Console.WriteLine($"{item.Id}. {item.Name}");
            //}

            //using (var dbContext = new StudentDbContext())
            //{
            //    var s = new Student { Name = "Nima", BirthDate = new DateTime(2007, 08, 09) };
            //    dbContext.Students.Add(s);
            //    dbContext.SaveChanges();
            //}

            //using (var dbContext = new StudentDbContext())
            //{
            //    var s = dbContext.Students.FirstOrDefault(x => x.Id == 1);

            //    if (s != null)
            //    {
            //        s.Name = "Nima";
            //    }

            //    dbContext.SaveChanges();
            //}

            //using (var dbContext = new StudentDbContext())
            //{
            //    var s = new Student { Id = 1 };
            //    dbContext.Students.Remove(s);
            //    dbContext.SaveChanges();
            //}

            //var s = new Student { Name = "Nima", BirthDate = new DateTime(2007, 08, 09), Id = 2 };
            //using (var dbContext = new StudentDbContext())
            //{
            //    dbContext.Attach<Student>(s);
            //    s.Name = "Hosein";
            //    dbContext.SaveChanges();
            //}

            //var s = new Student { Id = 2};
            //using (var dbContext = new StudentDbContext())
            //{

            //    dbContext.Students.Remove(s);
            //    dbContext.SaveChanges();
            //}


            //using (var dbContext = new StudentDbContext())
            //{

            //    var s1 = new Student { Id = 7 };
            //    var s2 = new Student { Id = 3 };
            //    dbContext.Attach<Student>(s1);
            //    dbContext.Attach<Student>(s2);
            //    s1.BirthDate = new DateTime(2000, 1, 1);
            //    s2.BirthDate = new DateTime(2001, 1, 1);
            //    dbContext.SaveChanges();
            //}



            //using (var dbContext = new StudentDbContext())
            //{
            //    var s1 = new Student { Id = 7 };
            //    var s2 = new Student { Id = 3 };
            //    //dbContext.Students.RemoveRange(new Student[] { s1, s2 });
            //    dbContext.Students.RemoveRange(s1, s2);
            //    dbContext.SaveChanges();
            //}


            //Teacher t = null;

            //using (var dbContext = new StudentDbContext())
            //{
            //    //Eager Loading
            //    //    var teacher = dbContext.Teachers.Include(x => x.Students).FirstOrDefault();

            //    //Explicit Loading
            //    //var teacher = dbContext.Teachers.FirstOrDefault();
            //    //dbContext.Entry(teacher).Collection(x => x.Students).Load();

            //    //Lazy Loading
            //    //var teacher = dbContext.Teachers.FirstOrDefault();
            //    //Console.WriteLine(teacher.Students.Count);

            //    t = dbContext.Teachers.FirstOrDefault();
            //}

            //using (var dbContext = new StudentDbContext())
            //{
            //    var studentsList = dbContext.Students.ToList();
            //}


            //Console.WriteLine(t.Students.Count);
            #endregion EF

            #region params
            //var a = Add(1, 2, 3);
            //var b = Add(1);
            //var c = Add();
            //var d = Add(new int[] { 1,2,3,4,5});
            #endregion params

            #region Reflection
            var formulaNames = CalculationFormulaFactory.GetAll();
            var formula      = CalculationFormulaFactory.Create(formulaNames[0].TypeName);
            var share        = formula.Calculate(null, null, 1);
            #endregion Reflection
            Console.WriteLine("Done");
            Console.ReadLine();
        }
Example #5
0
 public async Task <IEnumerable <FormulaName> > GetFormulas()
 {
     return(await Task.Run(() => CalculationFormulaFactory.GetAll()));
 }