/// <summary> /// 修改一个实体 /// </summary> /// <param name="entity">实体</param> /// <returns></returns> public int Edit(SysSample entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.Set <SysSample>().Attach(entity); db.Entry <SysSample>(entity).State = EntityState.Modified; return(db.SaveChanges()); } }
public int Edit(MIS_Article_Category entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.MIS_Article_Category.Attach(entity); //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); db.Entry <MIS_Article_Category>(entity).State = EntityState.Modified; return(db.SaveChanges()); } }
public int Edit(Flow_FormContentStepCheck entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.Flow_FormContentStepCheck.Attach(entity); db.Entry <Flow_FormContentStepCheck>(entity).State = System.Data.Entity.EntityState.Modified; //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return(db.SaveChanges()); } }
public int Edit(WC_OfficalAccounts entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.WC_OfficalAccounts.Attach(entity); db.Entry <WC_OfficalAccounts>(entity).State = EntityState.Modified; //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return(db.SaveChanges()); } }
public int Edit(SysRole entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.SysRole.Attach(entity); //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); db.Entry <SysRole>(entity).State = EntityState.Modified; return(db.SaveChanges()); } }
public int Edit(WC_MessageResponse entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.WC_MessageResponse.Attach(entity); db.Entry <WC_MessageResponse>(entity).State = EntityState.Modified; //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return(db.SaveChanges()); } }
public int Edit(Flow_Form entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.Flow_Form.Attach(entity); db.Entry <Flow_Form>(entity).State = EntityState.Modified; //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return(db.SaveChanges()); } }
public int Edit(UserModel entity) { using (AppsDBEntities db = new AppsDBEntities()) { var user = db.SysUser.FirstOrDefault(u => u.Id == entity.Id); user.Name = entity.Name; user.Bir = entity.Bir; user.Age = entity.Age; user.Photo = entity.Photo; user.Note = entity.Note; db.SysUser.Attach(user); db.Entry <SysUser>(user).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } }
public bool PostData(WC_MessageResponse model) { //如果所有开关都关掉,证明不启用回复 if (model.Category == null) { return(true); } //全部设置为不默认 ExecuteSqlCommand(string.Format("Update [dbo].[WC_MessageResponse] set IsDefault=0 where OfficalAccountId='{0}' and MessageRule={1}", model.OfficalAccountId, model.MessageRule)); //默认回复和订阅回复,且不是图文另外处理,因为他们有三种模式,但是只有一个是默认的 if (model.Category != (int)WeChatReplyCategory.Image && (model.MessageRule == (int)WeChatRequestRuleEnum.Default || model.MessageRule == (int)WeChatRequestRuleEnum.Subscriber)) { //查看数据库是否存在数据 using (AppsDBEntities db = new AppsDBEntities()) { var entity = db.WC_MessageResponse.Where(p => p.OfficalAccountId == model.OfficalAccountId && p.MessageRule == model.MessageRule && p.Category == model.Category).FirstOrDefault(); if (entity != null) { //删除原来的 db.WC_MessageResponse.Remove(entity); } } } //全部设置为默认 ExecuteSqlCommand(string.Format("Update [dbo].[WC_MessageResponse] set IsDefault=1 where OfficalAccountId='{0}' and MessageRule={1} and Category={2}", model.OfficalAccountId, model.MessageRule, model.Category)); //修改 if (IsExist(model.Id)) { using (AppsDBEntities db = new AppsDBEntities()) { db.Entry <WC_MessageResponse>(model).State = EntityState.Modified; return(Edit(model) == 1 ? true : false); } } else { return(Create(model) == 1 ? true : false); } }