public IActionResult Edit(ProductLendVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState.GetErrorJson()));
     }
     else
     {
         vm.DoEdit(false);
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState.GetErrorJson()));
         }
         else
         {
             return(Ok(vm.Entity));
         }
     }
 }
        public void CreateTest()
        {
            ProductLendVM vm = _controller.Wtm.CreateVM <ProductLendVM>();
            ProductLend   v  = new ProductLend();

            v.PPName    = "v2oN";
            v.PPCompany = "Sza6IW";
            v.PPMan     = "IJ5X";
            v.PPTel     = "kpXu4";
            v.PPAddress = "nJ4OQ4";
            v.PPFax     = "m42oqLkCB";
            v.Email     = "6ajhl";
            v.PPUrl     = "yrt2p";
            v.PPBank    = "POf9cnR";
            v.PPGoods   = "VzWw6F";
            v.PPDesc    = "brh6";
            vm.Entity   = v;
            var rv = _controller.Add(vm);

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <ProductLend>().Find(v.ID);

                Assert.AreEqual(data.PPName, "v2oN");
                Assert.AreEqual(data.PPCompany, "Sza6IW");
                Assert.AreEqual(data.PPMan, "IJ5X");
                Assert.AreEqual(data.PPTel, "kpXu4");
                Assert.AreEqual(data.PPAddress, "nJ4OQ4");
                Assert.AreEqual(data.PPFax, "m42oqLkCB");
                Assert.AreEqual(data.Email, "6ajhl");
                Assert.AreEqual(data.PPUrl, "yrt2p");
                Assert.AreEqual(data.PPBank, "POf9cnR");
                Assert.AreEqual(data.PPGoods, "VzWw6F");
                Assert.AreEqual(data.PPDesc, "brh6");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
        public void EditTest()
        {
            ProductLend v = new ProductLend();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.PPName    = "v2oN";
                v.PPCompany = "Sza6IW";
                v.PPMan     = "IJ5X";
                v.PPTel     = "kpXu4";
                v.PPAddress = "nJ4OQ4";
                v.PPFax     = "m42oqLkCB";
                v.Email     = "6ajhl";
                v.PPUrl     = "yrt2p";
                v.PPBank    = "POf9cnR";
                v.PPGoods   = "VzWw6F";
                v.PPDesc    = "brh6";
                context.Set <ProductLend>().Add(v);
                context.SaveChanges();
            }

            ProductLendVM vm    = _controller.Wtm.CreateVM <ProductLendVM>();
            var           oldID = v.ID;

            v    = new ProductLend();
            v.ID = oldID;

            v.PPName    = "IUBI5yl";
            v.PPCompany = "wAt";
            v.PPMan     = "ws9LAcKGM";
            v.PPTel     = "hAi8";
            v.PPAddress = "HElI1hP";
            v.PPFax     = "uzO";
            v.Email     = "I1kyoqEnL";
            v.PPUrl     = "OvZWiPl";
            v.PPBank    = "xdTSPahAz";
            v.PPGoods   = "dCaFM";
            v.PPDesc    = "Ec5RFf";
            vm.Entity   = v;
            vm.FC       = new Dictionary <string, object>();

            vm.FC.Add("Entity.PPName", "");
            vm.FC.Add("Entity.PPCompany", "");
            vm.FC.Add("Entity.PPMan", "");
            vm.FC.Add("Entity.PPTel", "");
            vm.FC.Add("Entity.PPAddress", "");
            vm.FC.Add("Entity.PPFax", "");
            vm.FC.Add("Entity.Email", "");
            vm.FC.Add("Entity.PPUrl", "");
            vm.FC.Add("Entity.PPBank", "");
            vm.FC.Add("Entity.PPGoods", "");
            vm.FC.Add("Entity.PPDesc", "");
            var rv = _controller.Edit(vm);

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <ProductLend>().Find(v.ID);

                Assert.AreEqual(data.PPName, "IUBI5yl");
                Assert.AreEqual(data.PPCompany, "wAt");
                Assert.AreEqual(data.PPMan, "ws9LAcKGM");
                Assert.AreEqual(data.PPTel, "hAi8");
                Assert.AreEqual(data.PPAddress, "HElI1hP");
                Assert.AreEqual(data.PPFax, "uzO");
                Assert.AreEqual(data.Email, "I1kyoqEnL");
                Assert.AreEqual(data.PPUrl, "OvZWiPl");
                Assert.AreEqual(data.PPBank, "xdTSPahAz");
                Assert.AreEqual(data.PPGoods, "dCaFM");
                Assert.AreEqual(data.PPDesc, "Ec5RFf");
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }