protected void btnOk_Click(object sender, EventArgs e) { using (BuyingClient client = BuyingClient.Create(Global.Address)) { GoodsChangeDto goods = new GoodsChangeDto { Id = Guid.Parse(lstGood.SelectedValue), NewName = txtNewGood.Text }; client.ChangeGoods(goods); } Response.Redirect("GoodsDirectory.aspx"); }
public void ChangeGoods(GoodsChangeDto goodsInfo) { #region Sql-запрос. /*if exists(select 1 from Goods where Id = @Id) begin update Goods set Name = @Name where Id = @Id end*/ #endregion using (EFUnitOfWork uow = new EFUnitOfWork("GoodsBuyingConnectionString")) using (var transaction = uow.BeginTransaction()) { Goods goods = uow.Goods.Get(goodsInfo.Id); if (goods != null) { goods.Name = goodsInfo.NewName; uow.Save(); } transaction.Commit(); } }