Exemplo n.º 1
0
        public JsonResult GetInfoClient()
        {
            var             result              = Json("", JsonRequestBehavior.AllowGet);
            int             currentuser         = clsCommon.getIdentity().Id;
            int             tenantid            = clsCommon.getIdentity().tenatId;
            tenant          ctenant             = (from t in db.tenant where t.tenantId == tenantid select t).FirstOrDefault();
            ChargifyConnect chargify            = clsCommon.Chargify;
            int             usercount           = 1;
            bool            validpaid           = false;
            ISubscription   currentSubscription = ChargifyTools.getSubscription(ctenant.billingRefNumber);

            if (currentSubscription != null)
            {
                int componentId = clsCommon.getComponentId(currentSubscription.Product.Handle);
                if (currentSubscription.State == SubscriptionState.Active)
                {
                    if (componentId > 0)
                    {
                        IComponentAttributes newInfo = chargify.GetComponentInfoForSubscription(currentSubscription.SubscriptionID, componentId);
                        usercount = Convert.ToInt32(newInfo.AllocatedQuantity + 1);
                    }
                }
                validpaid = true;
            }
            List <userLogin> users = (from u in db.userLogin where u.tenantId == tenantid && u.active == true select u).ToList();
            var tenantinfo         = (from obj in db.vw_Tenant
                                      where obj.tenantId == tenantid
                                      select new
            {
                paid = validpaid,
                Companyname = obj.companyName,
                AllocatedUsers = obj.allocatedUsers,
                address = obj.Address,
                owneremail = obj.email,
                codigoarea = obj.countryCode,
                phone = obj.number,
                ownerurl = obj.companyURL,
                //userscount = (from u in db.userLogin
                //              join ct in db.contact
                //              on u.contactId
                //              equals ct.contactId
                //              where u.tenantId == tenantid && u.active == true
                //              select new
                //              {
                //                  name = ct.name,
                //                  alias = u.userName,
                //                  email = ct.email
                //              }).ToList(),
                tenantconfigs = (from obj2 in db.genConfigName
                                 where obj2.genConfigNameGroupId == 1 && obj2.active == true
                                 orderby obj2.code ascending
                                 select new
                {
                    configNameid = obj2.genConfigNameId,
                    parameter = "",
                    active = obj2.active,
                    code = obj2.code
                }).ToList(),
                settconfigs = (from obj3 in db.genConfigName
                               where obj3.genConfigNameGroupId == 2 && obj3.active == true
                               orderby obj3.code ascending
                               select new
                {
                    configNameid = obj3.genConfigNameId,
                    parameter = "",
                    active = obj3.active,
                    code = obj3.code
                }).ToList(),
                languanges = (from obj4 in db.genLanguage select new { obj4.name }).ToList(),
                currencies = (from obj5 in db.genCurrency select new { obj5.name, code = obj5.code }).ToList(),
                regions = (from obj6 in db.genRegion select new { obj6.name }).ToList(),
                Timezones = (from obj7 in db.genTimezone select new { obj7.timeZone }).ToList(),
                defaultconfigs = (from dcn in db.genConfigName
                                  join dc in db.genConfig
                                  on dcn.genConfigNameId equals dc.genConfigNameId
                                  where dc.tenantId == tenantid && dcn.genConfigNameGroupId == 1 && dcn.active == true
                                  orderby dcn.code ascending
                                  select new
                {
                    dcn.code,
                    dc.parameter
                }).ToList(),
                settdefaultconfigs = (from dcn in db.genConfigName
                                      join dc in db.genConfig
                                      on dcn.genConfigNameId equals dc.genConfigNameId
                                      where dc.tenantId == tenantid && dcn.genConfigNameGroupId == 2 && dcn.active == true
                                      orderby dcn.code ascending
                                      select new
                {
                    dcn.code,
                    dc.parameter
                }).ToList(),
                userroles = (from urol in db.userLoginRole where (urol.userLoginRoleId != 1 && urol.userLoginRoleId != 2)select new { name = urol.name, id = urol.userLoginRoleId }).ToList()
            }).FirstOrDefault();

            if (tenantinfo != null)
            {
                result = Json(tenantinfo, JsonRequestBehavior.AllowGet);
            }

            return(result);
        }
 /// <summary>
 /// Compare this IComponentAttributes to another
 /// </summary>
 public int CompareTo(IComponentAttributes other)
 {
     return(ComponentID.CompareTo(other.ComponentID));
 }