public async Task <ResultData <string> > InsertUserPassWord(TUserPassWord userPassWord) { try { UserPassWordService service = new UserPassWordService(); await service.InsertUserPassWord(userPassWord); return(await OutDataAsync()); } catch (Exception e) { return(await OutErrorAsync <string>(e.Message)); } }
/// <summary> /// 更新用户密码 /// </summary> /// <param name="userPassWord"></param> /// <returns></returns> public async Task UpdateUserPassWord(TUserPassWord userPassWord) { try { using (TemplateContext context = new TemplateContext()) { context.UserPassWords.Update(userPassWord); await context.SaveChangesAsync(); } } catch (Exception e) { throw ThrowException(e, "更新用户密码失败"); } }
public async Task <ResultData <TUserPassWord> > QueryUserPassWordById(string encryptId) { try { UserPassWordService service = new UserPassWordService(); int id = int.Parse(_protector.Unprotect(encryptId)); TUserPassWord userPassWord = await service.QueryUserPassWordById(id); return(await OutDataAsync(userPassWord)); } catch (Exception e) { return(await OutErrorAsync <TUserPassWord>(e.Message)); } }
public async Task <ResultData <string> > UpdateUserPassWord(TUserPassWord userPassWord) { try { UserPassWordService service = new UserPassWordService(); userPassWord.Id = int.Parse(_protector.Unprotect(userPassWord.EncryptId)); await service.UpdateUserPassWord(userPassWord); return(await OutDataAsync()); } catch (Exception e) { return(await OutErrorAsync <string>(e.Message)); } }
/// <summary> /// 插入用户密码 /// </summary> /// <param name="userPassWord"></param> /// <returns></returns> public async Task InsertUserPassWord(TUserPassWord userPassWord) { try { using (TemplateContext context = new TemplateContext()) { await context.UserPassWords.AddAsync(userPassWord); await context.SaveChangesAsync(); } } catch (Exception e) { throw ThrowException(e, "插入用户密码失败"); } }
/// <summary> /// 删除用户密码 /// </summary> /// <param name="id">用户密码Id</param> /// <returns></returns> public async Task DeleteUserPassWordById(int id) { try { using (TemplateContext context = new TemplateContext()) { TUserPassWord userPassWord = await context.UserPassWords.FirstOrDefaultAsync(o => o.Id == id); if (userPassWord != null) { context.UserPassWords.Remove(userPassWord); await context.SaveChangesAsync(); } } } catch (Exception e) { throw ThrowException(e, "删除用户密码失败"); } }