public ResponseCurrencyUpdate CurrencyUpdate(RequestCurrencyUpdate request) { ResponseCurrencyUpdate response = new ResponseCurrencyUpdate(); using (cnn = GetConnection()) { var ts = cnn.BeginTransaction(); try { var user = this.UserInfoGet(request.Token, ts); var d = cnn.Query("select * from tks_fas_Currency where code=@Code and id<>@Id", new { Code = request.Data.Code, Id = request.Data.Id }, ts); if (d.Count() > 0) { throw new NormalException("编码已经存在"); } d = cnn.Query("select * from tks_fas_Currency where name=@Name and id<>@Id", new { Name = request.Data.Name, Id = request.Data.Id }, ts); if (d.Count() > 0) { throw new NormalException("名称已经存在"); } string sql = @"update tks_fas_Currency set code=@Code, name=@Name, exchangeRate=@ExchangeRate where id=@Id"; var r = cnn.Execute(sql, request.Data, ts); if (r == 1) { ts.Commit(); response.IsSuccess = true; response.Message = "更新成功"; return(response); } else { throw new AppException(user.User.UserName, "CurrencyUpdate", "数据更新异常", r + "行数据被更新"); } } catch (Exception ex) { ts.Rollback(); return(this.DealException(response, ex) as ResponseCurrencyUpdate); } } }
public ResponseCurrencyUpdate CurrencyUpdate([FromBody] RequestCurrencyUpdate request) { try { CurrencyBLL bll = new CurrencyBLL(); return(bll.CurrencyUpdate(request)); } catch (Exception ex) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }