Esempio n. 1
0
        public void CreateTest()
        {
            OtherInDepotVM vm = _controller.Wtm.CreateVM <OtherInDepotVM>();
            OtherInDepot   v  = new OtherInDepot();

            v.OIDID    = "yL1";
            v.DepotsID = AddDepots();
            v.OIDState = SCMSupplyChain.Model.OIDState.未定义3;
            v.OIDDesc  = "B78t";
            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 <OtherInDepot>().Find(v.ID);

                Assert.AreEqual(data.OIDID, "yL1");
                Assert.AreEqual(data.OIDState, SCMSupplyChain.Model.OIDState.未定义3);
                Assert.AreEqual(data.OIDDesc, "B78t");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
Esempio n. 2
0
        public void EditTest()
        {
            OtherInDepot v = new OtherInDepot();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.OIDID    = "yL1";
                v.DepotsID = AddDepots();
                v.OIDState = SCMSupplyChain.Model.OIDState.未定义3;
                v.OIDDesc  = "B78t";
                context.Set <OtherInDepot>().Add(v);
                context.SaveChanges();
            }

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

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

            v.OIDID    = "LBNoMk";
            v.OIDState = SCMSupplyChain.Model.OIDState.未定义2;
            v.OIDDesc  = "61VH";
            vm.Entity  = v;
            vm.FC      = new Dictionary <string, object>();

            vm.FC.Add("Entity.OIDID", "");
            vm.FC.Add("Entity.DepotsID", "");
            vm.FC.Add("Entity.OIDState", "");
            vm.FC.Add("Entity.OIDDesc", "");
            var rv = _controller.Edit(vm);

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

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

                Assert.AreEqual(data.OIDID, "LBNoMk");
                Assert.AreEqual(data.OIDState, SCMSupplyChain.Model.OIDState.未定义2);
                Assert.AreEqual(data.OIDDesc, "61VH");
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }
 public IActionResult Edit(OtherInDepotVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState.GetErrorJson()));
     }
     else
     {
         vm.DoEdit(false);
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState.GetErrorJson()));
         }
         else
         {
             return(Ok(vm.Entity));
         }
     }
 }