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

            CustomerContact contact = CustomerContext.Current.GetContactById(contactId);

            if (contact == null)
            {
                return(NotFound());
            }

            try
            {
                // BUG reported to Episerver. #COM-956
                contact.PreferredBillingAddressId  = null;
                contact.PreferredShippingAddressId = null;

                contact.SaveChanges();

                contact.DeleteWithAllDependents();
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(InternalServerError(exception));
            }

            return(Ok());
        }
Пример #2
0
        public virtual IHttpActionResult DeleteCart(Guid customerId, string name)
        {
            Logger.LogDelete("DeleteCart", Request, new [] { customerId.ToString(), name });

            if (string.IsNullOrEmpty(name))
            {
                name = _defaultName;
            }

            var existingCart = _orderRepository.Load <Cart>(customerId, name).FirstOrDefault();

            if (existingCart == null)
            {
                return(NotFound());
            }

            try
            {
                _orderRepository.Delete(new OrderReference(existingCart.OrderGroupId, name, customerId, typeof(Cart)));
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(InternalServerError(exception));
            }

            return(Ok());
        }
Пример #3
0
        public virtual IHttpActionResult DeleteOrder(int orderGroupId)
        {
            Logger.LogDelete("DeleteOrder", Request, new[] { orderGroupId.ToString() });

            var existingOrder = _orderRepository.Load <PurchaseOrder>(orderGroupId);

            if (existingOrder == null)
            {
                return(NotFound());
            }

            try
            {
                var orderReference = new OrderReference(orderGroupId, existingOrder.Name, existingOrder.CustomerId, typeof(PurchaseOrder));

                _orderRepository.Delete(orderReference);
                return(Ok());
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(InternalServerError(exception));
            }
        }