Beispiel #1
0
 public int Save(iPadRegister register)
 {
     using (var db = GetDbContext())
     {
         var entry = db.iPad_Registers.Find(register.ID);
         if (entry == null)
         {
             db.iPad_Registers.Add(register);
         }
         else
         {
             db.Entry(entry).CurrentValues.SetValues(register);
         }
         db.SaveChanges();
         return(register.ID);
     }
 }
Beispiel #2
0
 public ActionResult SaveRegister(iPadRegister register, int[] ipads)
 {
     if (ipads == null)
     {
         return(ErrorJsonResult("当前未选择平板,请选择"));
     }
     try
     {
         var rid  = Core.iPad_registerManager.Save(register);
         var list = ipads.Select(e => new Register_iPad {
             IID = e, RID = rid, Relation = Relation.Register_iPad
         }).ToList();
         Core.Register_iPadManager.Add(list, rid, Relation.Register_iPad);
         if (!Core.iPadManager.Update(ipads, iPadStatue.Borrow))
         {
             return(ErrorJsonResult("更改平板状态失败,请检查iPad使用状态"));
         }
     }
     catch (Exception ex)
     {
         return(ErrorJsonResult(ex.ToString()));
     }
     return(SuccessJsonResult());
 }