public BankEntity Update(BankEntity entity) { try { _bankRepository.Update(entity); return entity; } catch (Exception e) { _log.Error(e, "数据库操作出错"); return null; } }
public bool Delete(BankEntity entity) { try { _bankRepository.Delete(entity); return true; } catch (Exception e) { _log.Error(e, "数据库操作出错"); return false; } }
public HttpResponseMessage Update(BankEntity bank) { if (PageHelper.ValidateNumber(bank.Id.ToString()) && !string.IsNullOrEmpty(bank.Codeid)) { var bankEntity = _bankService.GetBankById(Convert.ToInt32(bank.Id)); bankEntity.Codeid = bank.Codeid; try { if (_bankService.Update(bankEntity) != null) { return PageHelper.toJson(PageHelper.ReturnValue(true, "数据更新成功!")); } } catch { return PageHelper.toJson(PageHelper.ReturnValue(false, "数据更新失败!")); } } return PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!")); }
public HttpResponseMessage AddBank([FromBody] BankEntity bank) { var entity = new BankEntity { Addtime = DateTime.Now, Codeid = bank.Codeid }; try { if (_bankService.Create(entity) != null) { return PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!")); } } catch { return PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!")); } return PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!")); }