public ResponseModel AddMenu(Menus menu) { ResponseModel response = new ResponseModel(); chargeContext.menus.Add(menu); chargeContext.SaveChanges(); return(response); }
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); })); }
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); }
public void Update(Charge charge) { _chargeDbContext.Entry(charge).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _chargeDbContext.SaveChanges(); }