/// <summary> /// 获取一个可用的对象 /// </summary> /// <returns></returns> public static SYS_LOGIN_BLL getInstance() { if (instance == null) { instance = new SYS_LOGIN_BLL(); } return(instance); }
/// <summary> /// 新增记录 /// </summary> /// <param name="model">待新增实体</param> /// <returns></returns> public bool BulkAdd(List <SYS_ROLE_USER> list, string userid) { bool success = false; using (var dbcontext = DbFactory.Create()) { try { //批量删除 int keyid = Convert.ToInt32(userid); Expression <Func <SYS_ROLE_USER, bool> > exp = a => a.UserID == keyid; dbcontext.Delete(exp); //批量插入 if (list != null && list.Count > 0) { foreach (var item in list) { dbcontext.Insert(item); } //改变授权状态 已授权 SYS_LOGIN loginmodel = SYS_LOGIN_BLL.getInstance().GetByUserID(userid); loginmodel.State = 1; dbcontext.Update(loginmodel); } else { //改变授权状态 未授权 SYS_LOGIN loginmodel = SYS_LOGIN_BLL.getInstance().GetByUserID(userid); loginmodel.State = 0; dbcontext.Update(loginmodel); } //保存 dbcontext.Save(); success = true; } catch (Exception ex) { Logger.Error(string.Format("SYS_ROLE_USER_BLL 新增记录异常,异常信息:{0}", ex.ToString())); } } return(success); }