public void CreateTest()
        {
            LostsVM vm = _controller.Wtm.CreateVM <LostsVM>();
            Losts   v  = new Losts();

            v.LostID    = "sWTrOWsWR";
            v.DepotsID  = AddDepots();
            v.LostDesc  = "Pzf0KpTYy";
            v.LostState = SCMSupplyChain.Model.LostState.未定义1;
            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 <Losts>().Find(v.ID);

                Assert.AreEqual(data.LostID, "sWTrOWsWR");
                Assert.AreEqual(data.LostDesc, "Pzf0KpTYy");
                Assert.AreEqual(data.LostState, SCMSupplyChain.Model.LostState.未定义1);
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
        public void EditTest()
        {
            Losts v = new Losts();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.LostID    = "sWTrOWsWR";
                v.DepotsID  = AddDepots();
                v.LostDesc  = "Pzf0KpTYy";
                v.LostState = SCMSupplyChain.Model.LostState.未定义1;
                context.Set <Losts>().Add(v);
                context.SaveChanges();
            }

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

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

            v.LostID    = "Gm3F7ECaV";
            v.LostDesc  = "6iJgee";
            v.LostState = SCMSupplyChain.Model.LostState.未定义1;
            vm.Entity   = v;
            vm.FC       = new Dictionary <string, object>();

            vm.FC.Add("Entity.LostID", "");
            vm.FC.Add("Entity.DepotsID", "");
            vm.FC.Add("Entity.LostDesc", "");
            vm.FC.Add("Entity.LostState", "");
            var rv = _controller.Edit(vm);

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

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

                Assert.AreEqual(data.LostID, "Gm3F7ECaV");
                Assert.AreEqual(data.LostDesc, "6iJgee");
                Assert.AreEqual(data.LostState, SCMSupplyChain.Model.LostState.未定义1);
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }
Beispiel #3
0
 public IActionResult Edit(LostsVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState.GetErrorJson()));
     }
     else
     {
         vm.DoEdit(false);
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState.GetErrorJson()));
         }
         else
         {
             return(Ok(vm.Entity));
         }
     }
 }