public async Task <ProvisionedServiceModel> GetServicesProvisionedToUser(string username, int companyId)
        {
            var companyProvisions = await _dbContext.Provisions.FirstOrDefaultAsync(p => p.CompanyId == companyId);

            if (companyProvisions == null)
            {
                return(null);
            }

            var userService = new ProvisionedServiceModel
            {
                ProductId = companyProvisions.ProductV2Id,
                Status    = UserProvisioningStatus.NotAvailable
            };

            var product = await _productService.GetProduct(userService.ProductId);

            userService.Name   = product.Name;
            userService.Vendor = product.Vendor;
            userService.ImgUrl = product.ImgUrl;

            userService.Status = await GetUserOffice365ProvisioningStatusforband(username);

            if (userService.Status != UserProvisioningStatus.Available)
            {
                return(userService);
            }

            var assignedLicense = await _office365DbLicenseService.GetUserAssgnedLicenseAsync(username);

            if (assignedLicense.Count > 0)
            {
                userService.AssignedLicense = string.Join(", ", assignedLicense.Select(x => x.OfferName));
            }
            //List<AssignedServicesModel> Assignli = new List<AssignedServicesModel>();
            //assignedLicense.ForEach(ass => {
            //    AssignedServicesModel Al = new AssignedServicesModel()
            //    { cloudPlusProductIdentifier=ass.CloudPlusProductIdentifier,
            //      offerName= ass.OfferName,
            //       Status= GetUserOffice365ProvisioningStatus(username, ass.CloudPlusProductIdentifier)
            //    };
            //});
            userService.AssignedLicenses = assignedLicense.Select(x => new AssignedServicesModel()
            {
                cloudPlusProductIdentifier = x.CloudPlusProductIdentifier,
                offerName = x.OfferName,
                Status    = GetUserOffice365ProvisioningStatus(username, x.CloudPlusProductIdentifier)
            }).ToList();

            return(userService);
        }
示例#2
0
        public static UserServiceViewModel ToUserServiceViewModel(this ProvisionedServiceModel provisionedService)
        {
            if (provisionedService == null)
            {
                return(null);
            }

            return(new UserServiceViewModel
            {
                ProductId = provisionedService.ProductId,
                ImgUrl = provisionedService.ImgUrl,
                Name = provisionedService.Name,
                Status = provisionedService.Status,
                Vendor = provisionedService.Vendor,
                AssignedLicense = provisionedService.AssignedLicense,
                AssignedLicenses = provisionedService.AssignedLicenses
            });
        }