public int CreateNewOrder(OrderDTO order)
 {
     try
     {
         return this.Create(order);
     }
     catch (BusinessException exception)
     {
         throw new FaultException(exception.Message, new FaultCode("Error"));
     }
 }
 public int CreateNewOrder(OrderDTO order)
 {
     try
     {
         return this.Create(order);
     }
     catch (BusinessException)
     {
         throw new WebFaultException(HttpStatusCode.InternalServerError);
     }
 }
        protected int Create(OrderDTO order)
        {
            if (order == null)
            {
                throw new BusinessException("Order should be defined.");
            }

            order.OrderDate = null;
            order.ShippedDate = null;

            var orderId = this.DataService.InsertOrder(Mapper.Map<OrderDTO, Order>(order));

            return orderId;
        }
        public int CreateNewOrder(OrderDTO order)
        {
            if (order == null)
            {
                throw new FaultException(new FaultReason("Order should be defined."), new FaultCode("Error"));
            }

            order.OrderDate = null;
            order.ShippedDate = null;

            var orderId = this.ordersDataService.InsertOrder(Mapper.Map<OrderDTO, Order>(order));

            return orderId;
        }
 public void UpdateOrder(OrderDTO order)
 {
     try
     {
         this.Update(order);
     }
     catch (BusinessException exception)
     {
         throw new FaultException(exception.Message, new FaultCode("Error"));
     }
     catch (EntityNotFoundException exception)
     {
         throw new FaultException(new FaultReason(exception.Message), new FaultCode("Error"));
     }
 }
 public void UpdateOrder(OrderDTO order)
 {
     try
     {
         this.Update(order);
     }
     catch (BusinessException)
     {
         throw new WebFaultException(HttpStatusCode.InternalServerError);
     }
     catch (EntityNotFoundException)
     {
         throw new WebFaultException(HttpStatusCode.NotFound);
     }
 }
        protected void Update(OrderDTO order)
        {
            if (order == null)
            {
                throw new BusinessException("Order should be defined.");
            }

            var orderEntity = Mapper.Map<OrderDTO, Order>(order);

            var sourceOrder = this.DataService.GetById(order.OrderId);

            if (!Mapper.Map<Order, OrderDTO>(sourceOrder).OrderState.Equals(OrderState.New))
            {
                throw new BusinessException("Only Order in New status can be modified.");
            }

            // fields OrderDate and ShippedDate can not be modified directly
            // so restore these fields from source object
            orderEntity.OrderDate = sourceOrder.OrderDate;
            orderEntity.ShippedDate = sourceOrder.ShippedDate;

            this.DataService.UpdateOrder(orderEntity);
        }
        public void UpdateOrder(OrderDTO order)
        {
            if (order == null)
            {
                throw new FaultException(new FaultReason("Order should be defined."), new FaultCode("Error"));
            }

            try
            {
                var orderBO = Mapper.Map<OrderDTO, Order>(order);

                var sourceOrder = this.ordersDataService.GetById(order.OrderId);

                if (!Mapper.Map<Order, OrderDTO>(sourceOrder).OrderState.Equals(OrderState.New))
                {
                    throw new FaultException(new FaultReason("Only Order in New status can be modified."), new FaultCode("Error"));
                }

                // fields OrderDate and ShippedDate can not be modified directly
                // so restore these fields from source object
                orderBO.OrderDate = sourceOrder.OrderDate;
                orderBO.ShippedDate = sourceOrder.ShippedDate;

                this.ordersDataService.UpdateOrder(orderBO);
            }
            catch (EntityNotFoundException exception)
            {
                throw new FaultException(new FaultReason(exception.Message), new FaultCode("Error"));
            }
        }