public void Put([FromBody] ProductRequest request) { var d1 = new DateTime(0001, 01, 01, 00, 00, 00); using (var session = sessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { var productRepository = new Repository <Product>(session); var p1 = productRepository.GetById(request.Id); if (!string.IsNullOrEmpty(request.Name)) { p1.Name = request.Name; } if (!string.IsNullOrEmpty(request.Color)) { p1.Color = request.Color; } if (!(request.Price == 0)) { p1.Price = request.Price; } if (!(request.ExpirationDate == d1)) { p1.ExpirationDate = request.ExpirationDate; } if (!string.IsNullOrEmpty(request.Country)) { p1.Country = request.Country; } productRepository.Save(p1); transaction.Commit(); } } }
public void Put(Guid uid, ProductRequest request) { var(name, description, price) = request; _productService.UpdateProduct(uid, name, description, price); }