/// <summary> /// 編輯帳號資料 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <VerityResult> EditUserItem(UserViewModel model) { VerityResult result = new VerityResult(); try { var query = _user.FindBy(x => x.ur_id == model.ur_id); if (query.Any()) { var list = query.FirstOrDefault(); user item = list; item.ur_ac = model.ur_ac; string Md5Str = MD5Str.MD5(model.ur_pw); item.ur_pw = Md5Str; if (!string.IsNullOrEmpty(model.ur_im)) { item.ur_im = model.ur_im; } _user.Update(item); } result.Success = true; result.Message = "編輯帳號資料成功"; } catch { result.Success = false; result.Message = "編輯帳號資料失敗"; } return(await Task.Run(() => result)); }
/// <summary> /// 新增帳號 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <VerityResult> CreateUser(CreateUserViewModel model) { VerityResult result = new VerityResult(); user AddUser = new user() { ur_id = Guid.NewGuid().ToString(), ur_ac = model.ur_ac, ur_pw = MD5Str.MD5(model.ur_pw), ur_ct = DateTime.Now, ur_is = true, ur_im = model.ur_im }; try { _user.Create(AddUser); result.Success = true; result.Message = "新增帳號成功"; } catch { result.Success = false; result.Message = "新增帳號失敗"; } return(await Task.Run(() => result)); }