Exemplo n.º 1
0
        //Xóa Brand
        public async Task <bool> Delete(object id)
        {
            var Plan = _repoPlan.FindById(id);

            _repoPlan.Remove(Plan);
            return(await _repoPlan.SaveAll());
        }
Exemplo n.º 2
0
        //Xóa Brand
        public async Task <bool> Delete(object id)
        {
            var Plan = _repoPlan.FindById(id);

            _repoPlan.Remove(Plan);
            await _hubContext.Clients.All.SendAsync("summaryRecieve", "ok");

            return(await _repoPlan.SaveAll());
        }
        public async Task <SubscriptionResponse> SaveAsync(Subscription subscription)
        {
            var existingUser = await _userRepository.FindById(subscription.UserId);

            if (existingUser == null)
            {
                return(new SubscriptionResponse("User not found"));
            }

            var existingPlan = await _planRepository.FindById(subscription.PlanId);

            if (existingPlan == null)
            {
                return(new SubscriptionResponse("Plan not found"));
            }

            subscription.Plan = existingPlan;
            subscription.User = existingUser;
            try
            {
                await _subscriptionRepository.SaveAsync(subscription);

                await _unitOfWork.CompleteAsync();

                return(new SubscriptionResponse(subscription));
            }
            catch (Exception e)
            {
                return(new SubscriptionResponse($"An error ocurred while saving the Subscription: {e.Message}"));
            }
        }
        public async Task <PlanResponse> DeleteAsync(int id)
        {
            var existingPlan = await _planRepository.FindById(id);

            if (existingPlan == null)
            {
                return(new PlanResponse("Plan not found"));
            }
            try
            {
                _planRepository.Remove(existingPlan);
                await _unitOfWork.CompleteAsync();

                return(new PlanResponse(existingPlan));
            }
            catch (Exception ex)
            {
                return(new PlanResponse($"An error ocurred while deleting plan: {ex.Message}"));
            }
        }