Example #1
0
        /// <summary>
        /// function to create the License  for multiple User . This function will be used for bulk license mapping to
        /// multiple User.
        /// </summary>
        /// <param name="licList"></param>
        /// <param name="userIdList"></param>
        /// <returns></returns>
        public bool CreateMultiUserLicense(UserLicenseDataMapping model)
        {
            LicenseLogic licLogic = new LicenseLogic();

            foreach (var userId in model.UserList)
            {
                var userLicList = Work.UserLicenseRepository.GetData(ul => ul.UserId == userId).ToList();
                foreach (var lic in model.LicenseDataList)
                {
                    var data = Work.LicenseDataRepository.GetData(l => l.ProductId == lic.ProductId && l.UserSubscriptionId == lic.UserSubscriptionId).ToList().Select(l => l.Id);
                    var obj  = userLicList.FirstOrDefault(ul => data.Contains(ul.LicenseId));
                    if (obj == null)
                    {
                        var         licId = licLogic.GetUnassignedLicense(lic.UserSubscriptionId, lic.ProductId).Id;
                        UserLicense ul    = new UserLicense()
                        {
                            UserId    = userId,
                            LicenseId = licId,
                            TeamId    = model.TeamId
                        };
                        CreateUserLicense(ul);
                    }
                    userLicList.Remove(obj);
                }
            }
            return(true);
        }
Example #2
0
        /// <summary>
        /// function to create the License  for multiple User . This function will be used for bulk license mapping to
        /// multiple User.
        /// </summary>
        /// <param name="licList">license List</param>
        /// <param name="userIdList">user Id List</param>
        /// <returns></returns>
        public bool CreateMultipleTeamLicense(TeamLicenseDataMapping model)
        {
            LicenseLogic licLogic = new LicenseLogic();

            foreach (var teamId in model.TeamList)
            {
                for (int concurrentUserIndex = 0; concurrentUserIndex < model.ConcurrentUserCount; concurrentUserIndex++)
                {
                    int id = int.Parse(teamId);
                    for (int index = 0; index < model.ProductIdList.Count; index++)
                    {
                        var         proId = model.ProductIdList[index];
                        var         data  = Work.LicenseDataRepository.GetData(l => l.ProductId == proId).ToList().Select(l => l.Id).ToList();
                        var         licId = licLogic.GetUnassignedLicenseForTeam(model.ProductIdList[index]);
                        TeamLicense tl    = new TeamLicense()
                        {
                            LicenseId = licId.Id,
                            TeamId    = id,
                            ProductId = proId
                        };
                        CreateTeamLicense(tl);
                    }
                }
            }
            return(true);
        }
        public LicenseLogicTest()
        {
            InitializerClass.Initialize();

            licLogic    = new Logic.DataLogic.LicenseLogic();
            userLogic   = new UserLogic();
            useSubLogic = new UserSubscriptionLogic();

            user = userLogic.GetUserByEmail("*****@*****.**");
            sub  = useSubLogic.GetSubscription(user.UserId).First();
        }
Example #4
0
        private bool CreateUserLicense(UserLicense lic)
        {
            var obj = AutoMapper.Mapper.Map <UserLicense, Core.Model.UserLicense>(lic);

            obj = Work.UserLicenseRepository.Create(obj);
            Work.UserLicenseRepository.Save();
            LicenseLogic licLogic = new LicenseLogic();

            licLogic.UpdateLicenseStatus(obj.LicenseId, true);
            return(obj.Id > 0);
        }
        public List <UserSubscription> GetSubscriptionByIDList(List <int> idList)
        {
            List <UserSubscription> subscriptionList = new List <UserSubscription>();
            LicenseLogic            logic            = new LicenseLogic();
            var subsList = Work.UserSubscriptionRepository.GetData(us => idList.Contains(us.Id));

            foreach (var obj in subsList)
            {
                var subObj = AutoMapper.Mapper.Map <Core.Model.UserSubscription, UserSubscription>(obj);
                subscriptionList.Add(subObj);
            }
            return(subscriptionList);
        }
        public List <UserSubscription> GetSubscription(string userId)
        {
            List <UserSubscription> subscriptionList = new List <UserSubscription>();
            LicenseLogic            logic            = new LicenseLogic();
            var subsList = Work.UserSubscriptionRepository.GetData(us => us.UserId == userId);

            foreach (var obj in subsList)
            {
                var subObj = AutoMapper.Mapper.Map <Core.Model.UserSubscription, UserSubscription>(obj);
                subscriptionList.Add(subObj);
            }
            return(subscriptionList);
        }
Example #7
0
        public UserLicenseLogicTest()
        {
            InitializerClass.Initialize();

            userLicLogic = new UserLicenseLogic();
            userLogic    = new UserLogic();
            licLogic     = new Logic.ServiceLogic.LicenseLogic();
            userLicLogic = new UserLicenseLogic();
            subLogic     = new UserSubscriptionLogic();
            AdminUser    = userLogic.GetUserByEmail("*****@*****.**");
            TeamMember   = userLogic.GetUserByEmail("*****@*****.**");
            Sub          = subLogic.GetSubscription(AdminUser.UserId).First();
            LicenseList  = licLogic.GetLicenseList(Sub.Id);
        }
Example #8
0
        public bool RevokeUserLicense(UserLicenseDataMapping model)
        {
            LicenseLogic licLogic = new LicenseLogic();

            foreach (var userId in model.UserList)
            {
                foreach (var lic in model.LicenseDataList)
                {
                    var obj = Work.UserLicenseRepository.GetData(l => l.UserId == userId && l.License.ProductId == lic.ProductId && l.License.UserSubscriptionId == lic.UserSubscriptionId && l.TeamId == model.TeamId).FirstOrDefault();
                    RevokeUserLicense(obj);
                }
            }
            return(true);
        }
Example #9
0
        private bool RevokeUserLicense(Core.Model.
                                       UserLicense lic)
        {
            var obj = Work.UserLicenseRepository.GetData(r => r.LicenseId == lic.LicenseId && r.UserId == lic.UserId).FirstOrDefault();

            if (obj == null)
            {
                return(false);
            }
            var obj1 = Work.UserLicenseRepository.Delete(obj);

            Work.UserLicenseRepository.Save();
            LicenseLogic licLogic = new LicenseLogic();

            licLogic.UpdateLicenseStatus(obj1.LicenseId, false);
            return(obj1 != null);
        }