Example #1
0
        private async Task NoticeSubs(CProfile profileFrom, string link, bool isModifyed = false)
        {
            string text;

            if (isModifyed)
            {
                text = $"Пользователь {profileFrom.User.UserName} обновил";
            }
            else
            {
                text = $"Пользователь {profileFrom.User.UserName} опубликовал";
            }

            var subs = await subService.GetSubscribers(profileFrom.Id);

            var alt = "статью";

            List <Notification> notifications = new List <Notification>();

            await Task.Run(() =>
                           subs
                           .ForEach(sub =>
            {
                var profileTo = profileService.GetSimpleProfileById(sub.ProfileID);

                var notification = new Notification
                {
                    NotificationDate = DateTime.Now,
                    ProfileIdFrom    = profileFrom.Id,
                    Profile          = profileTo.Result,
                    NotificationText = text,
                    Url       = link,
                    Alt       = alt,
                    CommentId = null
                };
                notifications.Add(notification);
            }));

            await context.Notifications.AddRangeAsync(notifications);

            await context.SaveChangesAsync();
        }
Example #2
0
        public async Task <ActionResult> GetSubscribersById(GetSubscribersByIdModel model)
        {
            var result = await subService.GetSubscribers(model.ProfileId, model.Page);

            return(Ok(result));
        }