Beispiel #1
0
        public IActionResult SubscribedUsersForPlan(int id)
        {
            List <TenantPlan>      subscribedTenantIds = _tenantPlanRepository.GetAll().Where(entity => entity.PlanId == id).ToList();
            IList <SubscribedUser> subscribedUser      = new List <SubscribedUser>();

            foreach (var tenantPlan in subscribedTenantIds)
            {
                var details = _tenantRepository.GetById(tenantPlan.TenantId);
                if (details != null)
                {
                    subscribedUser.Add(new SubscribedUser()
                    {
                        Id         = details.Id,
                        FirstName  = details.FirstName,
                        LastName   = details.LastName,
                        PlanId     = id,
                        Subscribed = true
                    });
                }
            }
            var  claimsIdentity = this.User.Identity as ClaimsIdentity;
            var  userId         = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
            bool succes         = Int32.TryParse(userId, out var ownerId);

            if (succes)
            {
                var tenants = _tenantRepository.GetAll().Where(t => t.OwnerId == ownerId).ToList();
                foreach (var subscribedTenant in subscribedUser)
                {
                    var tenant = tenants.Where(t => t.Id == subscribedTenant.Id).First();
                    tenants.Remove(tenant);
                }

                foreach (var t in tenants)
                {
                    subscribedUser.Add(new SubscribedUser()
                    {
                        Id         = t.Id,
                        FirstName  = t.FirstName,
                        LastName   = t.LastName,
                        PlanId     = id,
                        Subscribed = false
                    });
                }
            }

            return(Ok(subscribedUser));
        }
        public IList <PayPal.Api.Plan> GetPlansForTenant(int id)
        {
            IList <PayPal.Api.Plan> plans = new List <PayPal.Api.Plan>();
            var listOfPlanIds             = _tenantPlanRepository.GetAll().Where(entity => entity.TenantId == id).Select(e => e.PlanId).ToList();

            foreach (var planId in listOfPlanIds)
            {
                var plan = _paymentService.GetPlan(planId);
                if (plan != null)
                {
                    plans.Add(plan);
                }
            }

            return(plans);
        }
 public IList <TenantPlan> GetSubribedUsersId(int planid)
 {
     return(_tenantPlanRepository.GetAll().Where(en => en.PlanId == planid).ToList());
 }