Пример #1
0
        public virtual IHttpActionResult GetContact(Guid contactId)
        {
            Logger.LogGet("GetContact", Request, new[] { contactId.ToString() });

            Contact contact;

            try
            {
                contact = CustomerContext.Current.GetContactById(contactId).ConvertToContact();
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(InternalServerError(exception));
            }

            return(Ok(contact));
        }
Пример #2
0
        public virtual IHttpActionResult GetOrder(int orderGroupId)
        {
            Logger.LogGet("GetOrders", Request, new[] { orderGroupId.ToString() });

            try
            {
                var order = _orderRepository.Load <PurchaseOrder>(orderGroupId);
                if (order == null)
                {
                    return(NotFound());
                }

                return(Ok(order.ConvertToPurchaseOrder()));
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(InternalServerError(exception));
            }
        }
Пример #3
0
        public virtual IHttpActionResult GetCart(Guid customerId, string name)
        {
            Logger.LogGet("GetCart", Request, new [] { customerId.ToString(), name });
            if (string.IsNullOrEmpty(name))
            {
                name = _defaultName;
            }

            try
            {
                var cart = _orderRepository.Load <Cart>(customerId, name).FirstOrDefault()
                           ?? _orderRepository.Create <Cart>(customerId, name);
                return(Ok(cart));
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(InternalServerError(exception));
            }
        }