Exemplo n.º 1
0
 public TaxRules AddTaxRules(TaxRules rules)
 {
     //insert check if exists
     //_taxRules.Add(rules.TaxRuleNumber, rules);
     _liteDb.GetCollection <TaxRules>("TaxRules").Insert(rules);
     return(rules);
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Test2.Run();
            RealLifeDecorator.Run();
            Mackor.Run();



            var emp = new Employee {
                Name = "Stefan Holmberg sdadsadassdadadas", Salary = 342
            };
            var emp2 = new Employee {
                Name = "Stefan Holmberg sdadsadassdadadas", Salary = 342
            };

            emp2.Name = "423234";
            Console.WriteLine(emp.Name);

            //Hur kan vi kolla ifall två objekt är EXAKT samma
            //inte samma  värden



            //utan pekar på SAMMA objekt på heapen
            //1. sätt ett värde på den ena. Den andra ska då uppdateras
            //2. Skapa en Guid
            //3. ReferenceEquals



            bool f = Object.ReferenceEquals(emp, emp2);

            if (f)
            {
                Console.WriteLine("lika");
            }
            else
            {
                Console.WriteLine("not lika");
            }


            var tax1 = TaxRules.GetInstance();
            var tax2 = TaxRules.GetInstance();

            tax1.Version = "a";
            Console.WriteLine(tax2.Version);



            f = Object.ReferenceEquals(tax1, tax2);
            if (f)
            {
                Console.WriteLine("lika");
            }
            else
            {
                Console.WriteLine("not lika");
            }
        }
Exemplo n.º 3
0
 public static TaxRules GetInstance()
 {
     if (_theOnlyInstance == null)
     {
         _theOnlyInstance = new TaxRules();
     }
     return(_theOnlyInstance);
 }
Exemplo n.º 4
0
        public ActionResult <TaxRules> EditTaxRule(TaxRules rules)
        {
            var taxRules = _services.EditTaxRule(rules);

            if (taxRules == null)
            {
                return(NotFound());
            }
            return(taxRules);
        }
Exemplo n.º 5
0
        public void TaxRules_GivenTheCetsToRoundUpByIsWithinRange_ExpectingValidModel()
        {
            //arrage
            var taxRules = new TaxRules()
            {
                CentsToRoundUpBy = 5
            };

            //act
            var results = ModelValidationHelper.Validate(taxRules);

            //assert
            Assert.AreEqual(0, results.Count);
        }
Exemplo n.º 6
0
        public void TaxRules_GivenTheCetsToRoundUpByAreOutOfValidRange_ExpectingModelError()
        {
            //arrage
            var taxRules = new TaxRules()
            {
                CentsToRoundUpBy = 55
            };

            //act
            var results = ModelValidationHelper.Validate(taxRules);

            //assert
            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("CentsToRoundUpBy cannot be greater than 9 or less than 0.", results[0].ErrorMessage);
        }
Exemplo n.º 7
0
 public TaxRules EditTaxRule(TaxRules rules)
 {
     _liteDb.GetCollection <TaxRules>("TaxRules").Update(rules);
     return(rules);
 }