示例#1
0
        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);
            }
        }
示例#2
0
        public bool IsOrderSaved(Guid trackingId)
        {
            try
            {
                bool isOrderSubmitted = false;
                using (var context = new SalesOrderContext())
                {
                    using (var transactionScope = this.GetTransactionScope())
                    {
                        var orderEntity = context.SalesOrderHeaders.FirstOrDefault(o => o.TrackingId.Equals(trackingId));

                        if (orderEntity != null)
                        {
                            isOrderSubmitted = true;
                        }

                        transactionScope.Complete();
                    }
                }

                return(isOrderSubmitted);
            }
            catch (Exception e)
            {
                throw new RepositoryException(
                          string.Format(CultureInfo.CurrentCulture, Strings.ErrorCheckingOrderSubmission, trackingId),
                          e);
            }
        }
示例#3
0
        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);
            }
        }