Exemple #1
0
        public HttpResponseMessage DeleteRate(string RateSearchDTO)
        {
            RateSearchDTO dto          = TransformHelper.ConvertBase64JsonStringToDTO <RateSearchDTO>(RateSearchDTO);
            var           actionresult = _IBaseInfoServices.DeleteRate(dto);

            HttpResponseMessage result = new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(actionresult),
                                            System.Text.Encoding.GetEncoding("UTF-8"),
                                            "application/json")
            };

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 删除汇率信息
        /// </summary>
        /// <returns></returns>
        public bool DeleteRate(RateSearchDTO dto)
        {
            bool result = false;

            using (var tcdmse = new Entities.TCDMS_MasterDataEntities())
            {
                var pp = tcdmse.master_RateInfo.Where(p => p.RateID == dto.RateID).FirstOrDefault();
                if (pp == null)
                {
                    throw new Exception("此条信息不存在!");
                }
                tcdmse.master_RateInfo.Remove(pp);
                result = tcdmse.SaveChanges() > 0;
            }

            return(result);
        }
Exemple #3
0
        public void TestMethod1()
        {
            #region 汇率
            //新增
            testservice.GetRateList();
            RateOperateDTO addRatedto = new RateOperateDTO();
            addRatedto.CreateTime = DateTime.Now;
            addRatedto.CreateUser = "******";
            addRatedto.Currency   = "TestCurrencyTest";
            addRatedto.AprilRate  = (decimal)6.12;
            addRatedto.AugustRate = (decimal)6.2;
            addRatedto.DecRate    = (decimal)7.12;
            addRatedto.FebRate    = (decimal)12.9001;
            addRatedto.JulyRate   = (decimal)23.908;
            addRatedto.JuneRate   = (decimal)12.9;
            addRatedto.MarchRate  = (decimal)8.23;
            addRatedto.MayRate    = (decimal)12;
            addRatedto.MonthRate  = (decimal)7.098;
            addRatedto.NovRate    = (decimal)10.98;
            addRatedto.OctRate    = (decimal)7.90;
            addRatedto.RateBudget = (decimal)14;
            addRatedto.SepRate    = (decimal)13.1;
            addRatedto.RateCode   = "testratecode";
            addRatedto.RateYear   = 2017;
            var addrateresult = testservice.AddRate(addRatedto);
            Assert.AreEqual(addrateresult, true);
            var ratelist = testservice.GetRateList();
            var ra       = ratelist.Where(m => m.Currency == "TestCurrencyTest").FirstOrDefault();
            Assert.IsNotNull(ra);
            Assert.AreEqual(ra.RateCode, "testratecode");

            //修改
            addRatedto.RateID     = ra.RateID;
            addRatedto.Currency   = "TestCurrency";
            addRatedto.AprilRate  = (decimal)6.12;
            addRatedto.AugustRate = (decimal)6.2;
            addRatedto.DecRate    = (decimal)7.12;
            addRatedto.FebRate    = (decimal)12.9001;
            addRatedto.JulyRate   = (decimal)23.908;
            addRatedto.JuneRate   = (decimal)12.9;
            addRatedto.MarchRate  = (decimal)8.23;
            addRatedto.MayRate    = (decimal)12;
            addRatedto.MonthRate  = (decimal)7.098;
            addRatedto.NovRate    = (decimal)10.98;
            addRatedto.OctRate    = (decimal)7.90;
            addRatedto.RateBudget = (decimal)14;
            addRatedto.SepRate    = (decimal)13.1;
            addRatedto.RateCode   = "testratecodetest111";
            addRatedto.RateYear   = 2017;

            var updaterateresult = testservice.UpdateRate(addRatedto);
            var ratelist2        = testservice.GetRateList();
            var ra2 = ratelist2.Where(m => m.RateID == ra.RateID).FirstOrDefault();
            Assert.AreEqual(ra2.Currency, "TestCurrency");

            //删除
            RateSearchDTO ratedeletedto = new RateSearchDTO();
            ratedeletedto.RateID = ra.RateID;
            testservice.DeleteRate(ratedeletedto);
            var ratelist3 = testservice.GetRateList();
            var ra3       = ratelist3.Where(m => m.RateID == ra.RateID).FirstOrDefault();
            Assert.IsNull(ra3);
            #endregion
        }
Exemple #4
0
        public void TestMethod1()
        {
            //汇率
            //新增
            testcontroller.GetRateList();
            RateOperateDTO adddto = new RateOperateDTO();

            adddto.CreateTime = DateTime.Now;
            adddto.CreateUser = "******";
            adddto.Currency   = "TestCurrencyTest";
            adddto.AprilRate  = (decimal)6.12;
            adddto.AugustRate = (decimal)6.2;
            adddto.DecRate    = (decimal)7.12;
            adddto.FebRate    = (decimal)12.9001;
            adddto.JulyRate   = (decimal)23.908;
            adddto.JuneRate   = (decimal)12.9;
            adddto.MarchRate  = (decimal)8.23;
            adddto.MayRate    = (decimal)12;
            adddto.MonthRate  = (decimal)7.098;
            adddto.NovRate    = (decimal)10.98;
            adddto.OctRate    = (decimal)7.90;
            adddto.RateBudget = (decimal)14;
            adddto.SepRate    = (decimal)13.1;
            adddto.RateCode   = "testratecode";
            adddto.RateYear   = 2017;
            var addresult   = JsonConvert.DeserializeObject <bool>(testcontroller.AddRate(adddto).Content.ReadAsStringAsync().Result);
            var resultlist1 = JsonConvert.DeserializeObject <List <RateResultDTO> >(testcontroller.GetRateList().Content.ReadAsStringAsync().Result);
            var target      = resultlist1.Where(m => m.Currency == "TestCurrencyTest").FirstOrDefault();

            Assert.IsNotNull(target);

            //修改
            adddto.RateID     = target.RateID;
            adddto.Currency   = "TestCurrency";
            adddto.AprilRate  = (decimal)6.12;
            adddto.AugustRate = (decimal)6.2;
            adddto.DecRate    = (decimal)7.12;
            adddto.FebRate    = (decimal)12.9001;
            adddto.JulyRate   = (decimal)23.908;
            adddto.JuneRate   = (decimal)12.9;
            adddto.MarchRate  = (decimal)8.23;
            adddto.MayRate    = (decimal)12;
            adddto.MonthRate  = (decimal)7.098;
            adddto.NovRate    = (decimal)10.98;
            adddto.OctRate    = (decimal)7.90;
            adddto.RateBudget = (decimal)14;
            adddto.SepRate    = (decimal)13.1;
            adddto.RateCode   = "testratecodetest111";
            adddto.RateYear   = 2017;
            var updateresult = JsonConvert.DeserializeObject <bool>(testcontroller.UpdateRate(adddto).Content.ReadAsStringAsync().Result);
            var resultlist2  = JsonConvert.DeserializeObject <List <RateResultDTO> >(testcontroller.GetRateList().Content.ReadAsStringAsync().Result);

            target = resultlist2.Where(m => m.RateID == target.RateID && m.RateCode == "testratecodetest111").FirstOrDefault();
            Assert.IsNotNull(target);

            //删除
            RateSearchDTO deletedto = new RateSearchDTO();

            deletedto.RateID = target.RateID;
            var deletedtostr = TransformHelper.ConvertDTOTOBase64JsonString(deletedto);
            var deleteresult = JsonConvert.DeserializeObject <bool>(testcontroller.DeleteRate(deletedtostr).Content.ReadAsStringAsync().Result);
            var resultlist3  = JsonConvert.DeserializeObject <List <RateResultDTO> >(testcontroller.GetRateList().Content.ReadAsStringAsync().Result);

            target = resultlist3.Where(m => m.RateID == target.RateID).FirstOrDefault();
            Assert.IsNull(target);
        }