Example #1
0
        public IActionResult OnPostAsync()
        {
            if (_ApplicationUser.Id == "")
            {
                return(NotFound());
            }

            _ApplicationUser = _queries.GetAppicationUserFirstOrDefault(_ApplicationUser.Id);

            if (_ApplicationUser != null)
            {
                var serviciosListLocal = _queries.GetServiceLstIncludeApplicationUserWhereUserIdEquals(_ApplicationUser.Id);

                foreach (var service in serviciosListLocal)
                {
                    var orderDetailsLocal = _queries.GetAllOrderDetailsIncludeOrderServiceApplicationUserWhereServiceIdEquals(service.serviceId);

                    foreach (var orderDetails in orderDetailsLocal)
                    {
                        var quotationLocal = _queries.GetQuotationIncludeOrderDetailsTaskListMaterialPicturesFirstOrDefaultWhereOrderDetailsIdEquals(orderDetails.Id);

                        _orderDetailsRepository.Remove(orderDetails);
                        if (quotationLocal != null)
                        {
                            _quotationRepository.Remove(quotationLocal);
                        }
                        var _order = _queries.GetOrderFirstOrDefaultWhereOrderIdEquals(orderDetails.Order.Id);
                        if (_order != null)
                        {
                            var orderDetailsConEstaOrden = _queries.GetOrderDetailsIncludeOrderWhereOrderIdEquals(_order.Id);
                            if (orderDetailsConEstaOrden.Count > 0)
                            {
                            }
                            else
                            {
                                _orderRepository.Remove(_order);
                            }
                        }
                    }
                    _serviceRepository.Remove(service);
                }
                _applicationUserRepository.Remove(_ApplicationUser);
                _queries.SaveChanges();
            }
            return(RedirectToPage("./IndexUser"));
        }