예제 #1
0
 public ActionResult DoDistributionOrganization(VOS_TaskBatchVM vm)
 {
     using (var transaction = DC.BeginTransaction())
     {
         try
         {
             string        OrganizationID = GetAppointValue(vm.FC, "LinkedVM.OrganizationID").ToString();
             Guid          guid           = new Guid(OrganizationID);
             var           ids            = vm.Ids.ToList();
             List <string> _PlanId        = DC.Set <VOS_Task>().Where(x => ids.Contains(x.ID.ToString())).Select(x => x.PlanId.ToString()).ToList();
             foreach (var item in _PlanId)
             {
                 var _Plan = DC.Set <VOS_Plan>().Where(x => x.ID.ToString() == item).SingleOrDefault();
                 _Plan.OrganizationID = guid;
             }
             DC.SaveChanges();
             transaction.Commit();
             return(FFResult().CloseDialog().RefreshGrid().Alert("组织已分配"));
         }
         catch (Exception)
         {
             transaction.Rollback();
             return(FFResult().CloseDialog().RefreshGrid().Alert("组织分配失败"));
         }
     }
 }
예제 #2
0
 public ActionResult DoBatchDelete(VOS_TaskBatchVM vm, IFormCollection nouse)
 {
     if (!ModelState.IsValid || !vm.DoBatchDelete())
     {
         return(PartialView("BatchDelete", vm));
     }
     else
     {
         return(FFResult().CloseDialog().RefreshGrid().Alert(WalkingTec.Mvvm.Core.Program._localizer?["OprationSuccess"]));
     }
 }
예제 #3
0
        public void BatchDeleteTest()
        {
            VOS_Task v1 = new VOS_Task();
            VOS_Task v2 = new VOS_Task();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.Task_no        = "aSd4ySIyM";
                v1.PlanId         = AddPlan();
                v1.ComDis         = "efXZNA2uA";
                v1.CommodityName  = "b1gCJLeVc";
                v1.CommodityLink  = "HWLB7F0";
                v1.CommodityPrice = "2v0l0";
                v1.Commission     = "kY0";
                v1.OtherExpenses  = "4OzclEnJ";
                v2.Task_no        = "3sa";
                v2.PlanId         = v1.PlanId;
                v2.ComDis         = "5IUWTB";
                v2.CommodityName  = "A3v";
                v2.CommodityLink  = "0CK9YVAI";
                v2.CommodityPrice = "Zh3";
                v2.Commission     = "KLoc";
                v2.OtherExpenses  = "8FC1";
                context.Set <VOS_Task>().Add(v1);
                context.Set <VOS_Task>().Add(v2);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() });

            Assert.IsInstanceOfType(rv.Model, typeof(VOS_TaskBatchVM));

            VOS_TaskBatchVM vm = rv.Model as VOS_TaskBatchVM;

            vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() };
            _controller.DoBatchDelete(vm, null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <VOS_Task>().Count(), 2);
            }
        }
예제 #4
0
 public ActionResult DoBatchEdit(VOS_TaskBatchVM vm, IFormCollection nouse)
 {
     using (var transaction = DC.BeginTransaction())
     {
         try
         {
             var _CommodityPicId = GetAppointValue(vm.FC, "LinkedVM.CommodityPicId").ToString();
             var Ids             = GetAppointValue(vm.FC, "Ids").ToString().Split(',');
             foreach (var item in Ids)
             {
                 var _task = DC.Set <VOS_Task>().Where(x => x.ID.ToString() == item).FirstOrDefault();
                 _task.CommodityPicId = new Guid(_CommodityPicId);
                 DC.SaveChanges();
             }
             transaction.Commit();
             return(FFResult().CloseDialog().RefreshGrid().Alert("已批量修改图片"));
         }
         catch (Exception)
         {
             transaction.Rollback();
             return(FFResult().CloseDialog().RefreshGrid().Alert("批量修改图片失败"));
         }
     }
 }