public bool UpdateOrderStatus(Guid trackingId, OrderStatus newStatus) { try { using (var context = new SalesOrderContext()) { using (var transactionScope = this.GetTransactionScope()) { var orderEntity = context.SalesOrderHeaders.FirstOrDefault(o => o.TrackingId.Equals(trackingId)); if (orderEntity == null) { return(false); } orderEntity.Status = (byte)newStatus; var result = context.SaveChanges() > 0; transactionScope.Complete(); return(result); } } } catch (Exception e) { throw new RepositoryException( string.Format(CultureInfo.CurrentCulture, Strings.ErrorUpdatingOrderStatus, trackingId, newStatus), e); } }
public DE.Order SaveOrder(DE.Order order) { if (order == null) { throw new ArgumentNullException("order"); } try { var salesOrderHeader = new SalesOrderHeader(); Mapper.Map(order, salesOrderHeader); using (var context = new SalesOrderContext()) { using (var transactionScope = this.GetTransactionScope()) { context.SalesOrderHeaders.Add(salesOrderHeader); context.SaveChanges(); transactionScope.Complete(); } } return(order); } catch (Exception e) { throw new RepositoryException( string.Format(CultureInfo.CurrentCulture, Strings.ErrorSavingOrderWithTrackingId, order.TrackingId), e); } }