Esempio n. 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);
        }
 public void GetUnassignedLicense()
 {
     try
     {
         licLogic.GetUnassignedLicense(sub.Id, 1);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }