Пример #1
0
        public async Task ProductAssigned(Guid accountId, ViewOwnerProduct product, Account targetUser)
        {
            if (object.Equals(targetUser, null) || targetUser.Id == accountId)
            {
                return;
            }

            var ownerUser = await _auth.AccountGetAsync(accountId);

            var targetUserNotification = await CreateNotification(targetUser);

            var ownerUserNotification = await CreateNotification(ownerUser);

            var notification = new ProductAssignedNotification(targetUserNotification, product.ProductName, ownerUserNotification);

            if (targetUser.IsEmptyPassword())
            {
                var uri = await _auth.GeneratePasswordResetTokenLinkAsync(targetUser, _settings.CreatePassword);

                notification.CreatePasswordLink = uri.ToString();
            }

            if (product.IsPPC)
            {
                await _repository.SendProductEditionAssignedNotification(notification);
            }
            else
            {
                await _repository.SendProductAssignedNotification(notification);
            }
        }
Пример #2
0
        public async Task ProductUnassigned(Guid accountId, ViewOwnerProduct product, Account targetUser)
        {
            if (object.Equals(targetUser, null) || targetUser.Id == accountId)
            {
                return;
            }

            var ownerUser = await _auth.AccountGetAsync(accountId);

            var targetUserNotification = await CreateNotification(targetUser);

            var ownerUserNotification = await CreateNotification(ownerUser);

            var notification = new ProductAssignedNotification(targetUserNotification, product.ProductName, ownerUserNotification);

            await _repository.SendProductUnassignedNotification(notification);
        }
Пример #3
0
        public static OwnerProductViewModel OwnerAccountProductConvertor(ViewOwnerProduct product)
        {
            var newProduct = new OwnerProductViewModel();

            newProduct         = Mapper.Map(product, newProduct);
            newProduct.Modules = new List <AccountProductModuleModel>(); //create fake modules

            if (product.AllowedEsignCount.GetValueOrDefault(int.MaxValue) > 0)
            {
                newProduct.Modules.Add(new AccountProductModuleModel
                {
                    Module  = "e-sign",
                    Allowed = product.AllowedEsignCount,
                    Used    = product.UsedEsignCount
                });
            }

            return(newProduct);
        }
Пример #4
0
        public async Task ProductSuspend(Guid accountId, ViewOwnerProduct product, DateTime?nextRebillDate)
        {
            if (nextRebillDate.HasValue)
            {
                return;
            }

            if (product.EndDate.HasValue &&
                product.EndDate.Value > DateTime.UtcNow && (product.EndDate.Value - DateTime.UtcNow).TotalDays <= 10)
            {
                return;
            }

            var targetUser = await _auth.AccountGetAsync(accountId);

            var targetUserNotification = await CreateNotification(targetUser);

            var productSuspendNotification = new ProductSuspendNotification(targetUserNotification, product.ProductName, product.EndDate);

            await _repository.SendProductSuspendNotification(productSuspendNotification);
        }