/// <summary> /// 创建一个角色 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个角色</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, SysEntities db, SysRole entity) { int count = 1; foreach (string item in entity.SysPersonId.GetIdSort()) { SysPerson sys = new SysPerson { Id = item }; db.SysPerson.Attach(sys); entity.SysPerson.Add(sys); count++; } repository.Create(db, entity); if (count == repository.Save(db)) { return(true); } else { validationErrors.Add("创建出错了"); } return(false); }
public virtual bool Create(SysRoleModel model) { try { tbl_SysRole entity = m_Rep.GetById(model.Id); if (entity != null) { return(false); } entity = new tbl_SysRole(); entity.Id = model.Id; entity.RoleId = model.RoleId; entity.RoleName = model.RoleName; entity.IsShow = model.IsShow; if (m_Rep.Create(entity)) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }