/// <summary> /// 编辑一个AspNetUserLogins /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="entity">一个AspNetUserLogins</param> /// <returns></returns> public bool Edit(ref ValidationErrors validationErrors, AspNetUserLogins entity) { try { repository.Edit(db, entity); repository.Save(db); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
/// <summary> /// 修改密码 /// </summary> /// <param name="personName">用户名</param> /// <param name="oldPassword">旧密码</param> /// <param name="newPassword">新密码</param> /// <returns>修改密码是否成功</returns> public static bool ChangePassword(string personName, string oldPassword, string newPassword) { if (!string.IsNullOrWhiteSpace(personName) && !string.IsNullOrWhiteSpace(oldPassword) && !string.IsNullOrWhiteSpace(newPassword)) { try { if (AccountRepository.ChangePassword(personName, oldPassword, newPassword)) { return(true); } } catch (Exception ex) { ExceptionsHander.WriteExceptions(ex); } } return(false); }
/// <summary> /// 创建模块集合 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="entitys">模块集合</param> /// <returns></returns> public bool EditCollection(ref ValidationErrors validationErrors, IQueryable <SysMenu> entitys) { if (entitys != null) { try { int flag = 0, count = entitys.Count(); if (count > 0) { using (TransactionScope transactionScope = new TransactionScope()) { foreach (var entity in entitys) { if (Edit(ref validationErrors, db, entity)) { flag++; } else { Transaction.Current.Rollback(); return(false); } } if (count == flag) { transactionScope.Complete(); return(true); } } } } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } } return(false); }
/// <summary> /// 创建部门集合 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="entitys">部门集合</param> /// <returns></returns> public bool EditCollection(ref ValidationErrors validationErrors, IQueryable <SysDepartment> entitys) { try { if (entitys != null) { int count = entitys.Count(); if (count == 1) { return(this.Edit(ref validationErrors, entitys.FirstOrDefault())); } else if (count > 1) { using (TransactionScope transactionScope = new TransactionScope()) { repository.Edit(db, entitys); if (count == repository.Save(db)) { transactionScope.Complete(); return(true); } else { Transaction.Current.Rollback(); } } } } } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
/// <summary> /// 编辑一个模块 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="entity">一个模块</param> /// <returns>是否编辑成功</returns> public bool Edit(ref ValidationErrors validationErrors, SysMenu entity) { try { using (TransactionScope transactionScope = new TransactionScope()) { if (Edit(ref validationErrors, db, entity)) { transactionScope.Complete(); return(true); } else { Transaction.Current.Rollback(); } } } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }