public async Task <AccountSubscriptionModelApi <int> > SubscribeUserByIdDefaultAsync(int userId)
        {
            var sub = await _subscriptionRepository.GetByTitleAsync("Free");

            var rootFolder = await _rootFolderService.CreateRootFolderAsync();

            AccountSubscriptionModelBussines <int> model = new AccountSubscriptionModelBussines <int>
            {
                AccountId      = userId,
                IsActive       = true,
                TakenSpace     = 0,
                RootFolderId   = rootFolder.Id,
                SubscriptionId = sub.Id
            };

            NotificationModelBussines <int> notification = new NotificationModelBussines <int>()
            {
                Descritpion       = "You registered and signed in on Common subscription",
                NotificationState = SharedTypes.Enums.NotificationStateEnum.New,
                Title             = "Welcome to the service",
                AccountId         = userId
            };

            await this._notificationRepository.CreateAsync(notification);

            return(AutoMapperConfig.Mapper.Map <AccountSubscriptionModelApi <int> >(
                       await this._accountSubscriptionRepository.CreateAsync(model)
                       ));
        }
Пример #2
0
        public async Task <NotificationModelBussines <int> > CreateAsync(NotificationModelBussines <int> model)
        {
            var res = await _context.Notifications.AddAsync(
                AutoMapperConfig.Mapper.Map <NotificationModel <int> >(model)
                );

            await _context.SaveChangesAsync();

            return(await GetByIdAsync(res.Entity.Id));
        }
Пример #3
0
        internal async Task NotifyAboutSharing(string title, int recieverId)
        {
            var notification = new NotificationModelBussines <int>()
            {
                Descritpion       = $"Folder {title} shared with you!",
                Title             = $"Folder {title} shared with you!",
                NotificationState = SharedTypes.Enums.NotificationStateEnum.New,
                AccountId         = recieverId
            };

            var res = await this._notificationRepository.CreateAsync(notification);

            await this._signalRCommunicationService.SendNotificationSignalR(
                AutoMapperConfig.Mapper.Map <NotificationModelApi <int> >(res),
                recieverId);
        }
Пример #4
0
        private async Task NotifyAboutDeletetionAsync(int userId, string title)
        {
            var notification = new NotificationModelBussines <int>()
            {
                Descritpion       = $"{title} is deleted forever from your storage!",
                Title             = $"{title} is deleted!",
                NotificationState = SharedTypes.Enums.NotificationStateEnum.New,
                AccountId         = userId
            };

            var res = await this._notificationRepository.CreateAsync(notification);

            await this._signalRCommunicationService.SendNotificationSignalR(
                AutoMapperConfig.Mapper.Map <NotificationModelApi <int> >(res),
                userId);
        }
Пример #5
0
        public async Task <NotificationModelBussines <int> > UpdateAsync(int id, NotificationModelBussines <int> model)
        {
            var raw = await this.GetRawById(id);

            raw.IsDeleted = model.IsDeleted;

            raw.Title = model.Title ?? raw.Title;

            raw.Descritpion = model.Descritpion ?? raw.Descritpion;

            raw.NotificationState = model.NotificationState;

            _context.Notifications.Update(raw);

            await _context.SaveChangesAsync();

            return(await GetByIdAsync(id));
        }