public virtual async Task DeleteAsync(string[] ids)
        {
            using (var repository = _subscriptionRepositoryFactory())
            {
                var subscriptions = await GetByIdsAsync(ids);

                if (!subscriptions.IsNullOrEmpty())
                {
                    var changedEntries = subscriptions.Select(x => new GenericChangedEntry <Subscription>(x, EntryState.Deleted)).ToArray();
                    await _eventPublisher.Publish(new SubscriptionChangingEvent(changedEntries));

                    //Remove subscription order prototypes
                    var orderPrototypesIds = repository.Subscriptions.Where(x => ids.Contains(x.Id)).Select(x => x.CustomerOrderPrototypeId).ToArray();
                    await _customerOrderService.DeleteAsync(orderPrototypesIds);

                    await repository.RemoveSubscriptionsByIdsAsync(ids);

                    await repository.UnitOfWork.CommitAsync();

                    await _eventPublisher.Publish(new SubscriptionChangedEvent(changedEntries));

                    ClearCacheFor(subscriptions);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DeleteAsync(int customerId, int id)
        {
            var customer = await _customerOrderService.FindCustomerAsync(customerId);

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

            var result = await _customerOrderService.DeleteAsync(id);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            var orderResource = _mapper.Map <Order, CustomerOrderResource>(result.Order);

            return(Ok(orderResource));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> DeleteConfirmed(int pq, int customerID, int id)
        {
            ViewBag.Pq         = pq;
            ViewBag.CustomerID = customerID;

            try
            {
                await customerOrderService.DeleteAsync(id);

                return(RedirectToAction("../ProductQuote", new { pq = ViewBag.Pq, customerID = ViewBag.CustomerID }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }

            CustomerOrder customerOrder = await customerOrderRepository.FindCustomerOrdersByIDAsync(id);

            return(View("Details", customerOrder));
        }
        public async Task <ActionResult> DeleteOrdersByIds([FromQuery] string[] ids)
        {
            await _customerOrderService.DeleteAsync(ids);

            return(NoContent());
        }