Esempio n. 1
0
        public ResponseModel AddMenu(Menus menu)
        {
            ResponseModel response = new ResponseModel();

            chargeContext.menus.Add(menu);
            chargeContext.SaveChanges();

            return(response);
        }
Esempio n. 2
0
 public Task <Tuple <bool, ConstantDefine, string> > SaveConstantDefine(ConstantDefine constantDefine)
 {
     return(Task.Run(() => {
         var msg = "";
         var succ = true;
         var entity = chargeContext.constantDefines.AsNoTracking().Where(p => p.ID.Equals(constantDefine.ID)).FirstOrDefault();
         if (entity != null)
         {
             chargeContext.constantDefines.Update(constantDefine);
         }
         else
         {
             var entity1 = chargeContext.constantDefines.AsNoTracking().Where(p => (p.ConstantName.Equals(constantDefine.ConstantName) ||
                                                                                    p.ConsatntCode.Equals(constantDefine.ConsatntCode)) && p.TypeCode.Equals(constantDefine.TypeCode)).FirstOrDefault();
             if (entity1 == null)
             {
                 chargeContext.constantDefines.Add(constantDefine);
             }
             else
             {
                 succ = false;
                 msg = "常量名称/代号已存在";
             }
         }
         chargeContext.SaveChanges();
         return new Tuple <bool, ConstantDefine, string>(succ, constantDefine, msg);
     }));
 }
Esempio n. 3
0
        public ResponseModel DeleteUser(int id)
        {
            ResponseModel response = new ResponseModel();
            var           user     = chargeContext.users.Where(p => p.Id == id).FirstOrDefault();

            if (user != null)
            {
                chargeContext.users.Remove(user);
                chargeContext.SaveChanges();
            }
            return(response);
        }
Esempio n. 4
0
 public void Update(Charge charge)
 {
     _chargeDbContext.Entry(charge).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     _chargeDbContext.SaveChanges();
 }