public void NUnit_Domain_GetByIdCatCurrency()
 {
     Cat_CurrencyServices service = new Cat_CurrencyServices();
     var Currency = new Cat_Currency { Id = 2 };
     string status = string.Empty;
     var result = service.GetById<Cat_Currency>(Currency.Id, ref status);
     NUnit.Framework.Assert.IsNotNull(result);
     Console.Write("SearchResult: " + result.Id + " | " + result.CurrencyName + " | " + result.CurrencyCode + " | " + result.Description + " | " + result.DateCreate);
 }
        public void NUnit_Domain_GetByIdCatCurrency()
        {
            Cat_CurrencyServices service = new Cat_CurrencyServices();
            var Currency = new Cat_Currency {
                Id = 2
            };
            string status = string.Empty;
            var    result = service.GetById <Cat_Currency>(Currency.Id, ref status);

            NUnit.Framework.Assert.IsNotNull(result);
            Console.Write("SearchResult: " + result.Id + " | " + result.CurrencyName + " | " + result.CurrencyCode + " | " + result.Description + " | " + result.DateCreate);
        }
Exemple #3
0
        public static Double ConvertExtractRateToVND(Double moneyDest, Cat_Currency curDest, List <Cat_ExchangeRate> lstExchangeRate)
        {
            Double value  = 0;
            String curVND = CurrencyCode.VND.ToString();
            List <Cat_ExchangeRate> lstExchange = new List <Cat_ExchangeRate>();

            if (curVND == curDest.Code)
            {
                return(moneyDest);
            }
            //Lay Nguyen Te : VND | Ngoai Te : USD
            lstExchange = lstExchangeRate.Where(cur => cur.CurrencyDestID == curDest.ID && cur.Cat_Currency.Code == curVND)
                          .OrderByDescending(cu => cu.MonthOfEffect).ToList();
            if (lstExchange.Count <= 0)
            {
                //Neu lstExchange khong co thi lay nguoc lai Nguyen Te : USD | Ngoai te : VND
                lstExchange = lstExchangeRate.Where(cur => cur.CurrencyBaseID == curDest.ID && cur.Cat_Currency1.Code == curVND)
                              .OrderByDescending(cu => cu.MonthOfEffect).ToList();

                if (lstExchange.Count <= 0)
                {
                    throw new Exception("Currency " + curVND + " / " + curDest.Code + "not found ");
                }

                //Xu ly voi truong hop Nguyen Te : USD | Ngoai te : VND
                Cat_ExchangeRate exRate = lstExchange[0];
                //Vi doi tu USD sang VND nen phai lay gia mua
                if (exRate.BuyingRate == 0)
                {
                    throw new Exception("Exchange buying rate" + curDest.Code + " / " + curVND + "not found ");
                }

                if (exRate.BuyingRate.HasValue)
                {
                    value = moneyDest / exRate.BuyingRate.Value;
                }
                return(value);
            }

            //Xu ly voi truong hop Nguyen Te : VND | Ngoai te : USD
            Cat_ExchangeRate exRate1 = lstExchange[0];

            //Vi doi tu USD sang VND nen phai lay gia ban
            if (exRate1.SellingRate == 0)
            {
                throw new Exception("Exchange selling rate" + curVND + " / " + curDest.Code + "not found ");
            }


            value = moneyDest * exRate1.SellingRate;
            return(value);
        }
 public void NUnit_Domain_UpdateCatCurrency()
 {
     Cat_CurrencyServices service = new Cat_CurrencyServices();
     var Currency = new Cat_Currency
     {
         Id = 12,
         CurrencyName = "Update Currency Name Test",
         CurrencyCode = "Update tt",
         Description = "Update TestDES",
         DateCreate = DateTime.Now
     };
   //  NUnit.Framework.Assert.IsTrue(result);
     if (service.Edit<Cat_Currency>(Currency) == ActionStatus.EditSucceed.ToString())
     {
         Console.WriteLine("==>>> Result After Update:  " + Currency.Id + " | " + Currency.CurrencyName + " | " + Currency.CurrencyCode + " | " + Currency.Description + " | " + Currency.DateCreate);
     }
 }
        public void NUnit_Domain_UpdateCatCurrency()
        {
            Cat_CurrencyServices service = new Cat_CurrencyServices();
            var Currency = new Cat_Currency
            {
                Id           = 12,
                CurrencyName = "Update Currency Name Test",
                CurrencyCode = "Update tt",
                Description  = "Update TestDES",
                DateCreate   = DateTime.Now
            };

            //  NUnit.Framework.Assert.IsTrue(result);
            if (service.Edit <Cat_Currency>(Currency) == ActionStatus.EditSucceed.ToString())
            {
                Console.WriteLine("==>>> Result After Update:  " + Currency.Id + " | " + Currency.CurrencyName + " | " + Currency.CurrencyCode + " | " + Currency.Description + " | " + Currency.DateCreate);
            }
        }
        public void NUnit_Domain_DeleteCatCurrency()
        {
            Cat_CurrencyServices service = new Cat_CurrencyServices();
         
            int rs = 0;
            for (int i = 1; i <= 4; i++)
            {
                var Currency = new Cat_Currency { Id = i };

                if (service.Delete<Cat_Currency>(Currency.Id) == ActionStatus.DeleteSucceed.ToString())
                {
                    rs += 1;
                    Console.WriteLine("Process Success >>> Delete >>> " + i);
                }
            }
            Console.WriteLine("Total success record: " + rs);

            //NUnit.Framework.Assert.IsTrue(result);
        }
        public void NUnit_Domain_DeleteCatCurrency()
        {
            Cat_CurrencyServices service = new Cat_CurrencyServices();

            int rs = 0;

            for (int i = 1; i <= 4; i++)
            {
                var Currency = new Cat_Currency {
                    Id = i
                };

                if (service.Delete <Cat_Currency>(Currency.Id) == ActionStatus.DeleteSucceed.ToString())
                {
                    rs += 1;
                    Console.WriteLine("Process Success >>> Delete >>> " + i);
                }
            }
            Console.WriteLine("Total success record: " + rs);

            //NUnit.Framework.Assert.IsTrue(result);
        }
        public void NUnit_Domain_AddCatCurrency()
        {
            Cat_CurrencyServices service = new Cat_CurrencyServices();
 
            int rs = 0;
            for (int i = 0; i < 10; i++)
            {
                var Currency = new Cat_Currency
                {
                    CurrencyName = "Currency Name Test" + i,
                    CurrencyCode = "tt" + i,
                    Description = "TestDES" + i,
                    DateCreate = DateTime.Now
                };

                if (service.Add<Cat_Currency>(Currency) == ActionStatus.AddSucceed.ToString())
                {
                    rs += 1;
                    Console.WriteLine("Process Success >>> Create >>> " + Currency.Id + " | " + Currency.CurrencyName + " | " + Currency.CurrencyCode + " | " + Currency.Description + " | " + Currency.DateCreate);
                }
            }
            Console.WriteLine("Total success record: " + rs);
        }
        public void NUnit_Domain_AddCatCurrency()
        {
            Cat_CurrencyServices service = new Cat_CurrencyServices();

            int rs = 0;

            for (int i = 0; i < 10; i++)
            {
                var Currency = new Cat_Currency
                {
                    CurrencyName = "Currency Name Test" + i,
                    CurrencyCode = "tt" + i,
                    Description  = "TestDES" + i,
                    DateCreate   = DateTime.Now
                };

                if (service.Add <Cat_Currency>(Currency) == ActionStatus.AddSucceed.ToString())
                {
                    rs += 1;
                    Console.WriteLine("Process Success >>> Create >>> " + Currency.Id + " | " + Currency.CurrencyName + " | " + Currency.CurrencyCode + " | " + Currency.Description + " | " + Currency.DateCreate);
                }
            }
            Console.WriteLine("Total success record: " + rs);
        }