Exemplo n.º 1
0
        public string UpdateLicense(int concurrentUserCount, string[] selectedSubscription)
        {
            List <string> teamIdList = new List <string>();

            teamIdList.Add(TempData["Teamid"].ToString());
            List <int>             listOfProId = ExtractLicenseData(selectedSubscription);
            TeamLicenseDataMapping mapping     = new TeamLicenseDataMapping()
            {
                ConcurrentUserCount = concurrentUserCount, ProductIdList = listOfProId, TeamList = teamIdList
            };
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.PostAsJsonAsync("api/License/CreateTeamLicence", mapping).Result;

            if (!response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                return(response.ReasonPhrase + " - " + obj.Message);
            }
            else
            {
                if (teamIdList.Contains(LicenseSessionState.Instance.SelectedTeam.Id.ToString()))//doubt
                {
                    var subscriptionDetails = OnPremiseSubscriptionLogic.GetUserLicenseForUser();
                    LicenseSessionState.Instance.UserSubscriptionList = subscriptionDetails;
                }
            }
            return(String.Empty);
        }
Exemplo n.º 2
0
        //public ActionResult TeamList()
        //{
        //    return View(LicenseSessionState.Instance.TeamList);
        //}

        //[HttpPost]
        //public ActionResult TeamList(int teamId)
        //{
        //    LicenseSessionState.Instance.SelectedTeam = LicenseSessionState.Instance.TeamList.Where(t => t.Id == teamId).FirstOrDefault();
        //    var message = LoadUserLicense();
        //    return Json(new { success = true, message = message });
        //}

        public string LoadUserLicense()
        {
            LicenseSessionState.Instance.AppTeamContext = new Team()
            {
                Id      = LicenseSessionState.Instance.SelectedTeam.Id,
                AdminId = LicenseSessionState.Instance.SelectedTeam.AdminId,
                Name    = LicenseSessionState.Instance.SelectedTeam.Name
            };
            //if (LicenseSessionState.Instance.UserSubscriptionList == null || LicenseSessionState.Instance.UserSubscriptionList.Count == 0)
            //{
            var subscriptionDetails = OnPremiseSubscriptionLogic.GetUserLicenseForUser();

            LicenseSessionState.Instance.UserSubscriptionList = subscriptionDetails;
            //}
            return(string.Empty);
        }
        public string UpdateLicense(string[] SelectedSubscription, string action = "Add", string[] SelectedUserIdList = null, bool canAddBulkLicense = false)
        {
            List <string> userIdList = new List <string>();

            if (canAddBulkLicense)
            {
                foreach (var userId in SelectedUserIdList)
                {
                    userIdList.Add(userId);
                }
            }
            else
            {
                userIdList.Add(Convert.ToString(TempData["UserId"]));
            }

            List <LicenseData>     lstLicData = ExtractLicenseData(SelectedSubscription);
            UserLicenseDataMapping mapping    = new UserLicenseDataMapping()
            {
                TeamId = LicenseSessionState.Instance.SelectedTeam.Id, LicenseDataList = lstLicData, UserList = userIdList
            };
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.PostAsJsonAsync("api/License/CreateUserLicence", mapping).Result;

            if (!response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                return(response.ReasonPhrase + " - " + obj.Message);
            }
            else
            {
                if (userIdList.Contains(LicenseSessionState.Instance.User.UserId))
                {
                    var subscriptionDetails = OnPremiseSubscriptionLogic.GetUserLicenseForUser();
                    LicenseSessionState.Instance.UserSubscriptionList = subscriptionDetails;
                }
            }
            return(String.Empty);
        }