public void UpdateLinkPreview(Guid activityId, int previewId)
        {
            var relations = _previewRelationRepository.FindAll(r => r.ActivityId == activityId).ToList();

            _previewRelationRepository.Delete(relations);
            AddLinkPreview(activityId, previewId);
        }
示例#2
0
        public virtual void Remove(Guid entityId, IEnumerable <Guid> tagIds)
        {
            var tagIdsList = tagIds.AsList();

            if (tagIdsList.IsEmpty())
            {
                return;
            }
            var uniqueTagIds = tagIdsList.Distinct().AsList();

            _relationRepository.Delete(e => uniqueTagIds.Contains(e.UserTagId) && e.EntityId == entityId);
        }
        public Task DeleteAsync(TUser user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            //_userRepository.Delete(user);
            _repository.Delete <TUser>(new { id = user.Id });

            return(Task.FromResult(true));
        }
        /// <summary>Deletes the Attachment object defined by Id from Attachments table</summary>
        /// <param name="id">The Primary Key in Attachments</param>
        /// <param name="transaction">
        ///     An optional transaction parameter to be used
        ///     if action is to be performed under some transaction.
        /// </param>
        /// <returns></returns>
        public void DeleteAttachment(long id, SqlTransaction transaction = null)
        {
            int rowAffected;

            if (transaction == null)
            {
                rowAffected = _repo.Delete <Attachment>(id);
            }
            else
            {
                rowAffected = _repo.Delete <Attachment>(transaction, id);
            }

            if (rowAffected < 1)
            {
                throw new ApplicationException($"No {nameof(Attachment)} found to delete.");
            }
        }
示例#5
0
        public void RemovePreviewRelations(Guid commentId)
        {
            var relations  = _previewRelationRepository.FindAll(r => r.CommentId == commentId).ToList();
            var previewIds = relations.Select(r => r.LinkPreviewId).ToList();

            _previewRelationRepository.Delete(relations);
            foreach (var previewId in previewIds)
            {
                _previewRepository.Delete(previewId);
            }
        }
示例#6
0
        public Task DeleteAsync(TRole role)
        {
            if (role == null)
            {
                throw new ArgumentNullException("user");
            }

            //_roleRepository.Delete(role.Id);
            _repository.Delete <TRole>(new { id = role.Id });
            return(Task.FromResult <Object>(null));
        }
        public void RemovePreviewRelations(Guid activityId)
        {
            var relations  = _previewRelationRepository.FindAll(r => r.ActivityId == activityId).ToList();
            var previewIds = relations.Select(r => r.LinkPreviewId).ToList();

            _previewRelationRepository.Delete(relations);
            foreach (var previewId in previewIds)
            {
                if (_previewRepository.Exists(p => p.Id == previewId))
                {
                    _previewRepository.Delete(previewId);
                }
            }
        }
        protected virtual void Delete(Comment comment)
        {
            if (comment.ParentId == null)
            {
                var replies = GetReplies(comment);
                foreach (var reply in replies)
                {
                    Delete(reply);
                }
            }

            _commentLinkPreviewService.RemovePreviewRelations(comment.Id);
            _commentsRepository.Delete(comment);
        }
        public void Set(Guid activityId, ActivityLocation location)
        {
            var oldLocation = _locationRepository
                              .AsQueryable()
                              .SingleOrDefault(l => l.ActivityId == activityId);

            if (oldLocation is null)
            {
                if (location is null)
                {
                    return;
                }

                var newLocation = new ActivityLocationEntity()
                {
                    ActivityId   = activityId,
                    Address      = location.Address,
                    ShortAddress = location.ShortAddress
                };

                _locationRepository.Add(newLocation);
            }
            else
            {
                if (location?.Address == null || location.ShortAddress == null)
                {
                    _locationRepository.Delete(oldLocation);
                }
                else
                {
                    oldLocation.Address      = location.Address;
                    oldLocation.ShortAddress = location.ShortAddress;
                    _locationRepository.Update(oldLocation);
                }
            }
        }
示例#10
0
        protected virtual void Delete(Comment comment)
        {
            IEnumerable<Comment> GetDescendants(Comment current) =>
                    _commentsRepository
                    .FindAll(c => c.ParentId == current.Id)
                    .SelectMany(GetDescendants)
                    .Append(current);

            var commentsToDelete = GetDescendants(comment);

            commentsToDelete.ToList().ForEach(c =>
            {
                _commentLinkPreviewService.RemovePreviewRelations(c.Id);
                _commentsRepository.Delete(c);
            });
        }
示例#11
0
        public void Execute()
        {
            var parsedNotifications = _notificationRepository
                                      .GetAll()
                                      .Select(n => (item: n, data: n.Value.Deserialize <OldNotifierData>()))
                                      .Where(n => IsOldNotifierData(n.data))
                                      .Select(UpdateNotificationValue)
                                      .ToLookup(n => n.isValid);

            var invalidNotifications = parsedNotifications[false].Select(UnpackNotification);
            var updatedNotifications = parsedNotifications[true].Select(UnpackNotification); // notifications to activities that do not exist

            global::Uintra.Notification.Notification UnpackNotification((bool isValid, global::Uintra.Notification.Notification notification) arg) => arg.notification;

            _notificationRepository.Update(updatedNotifications);
            _notificationRepository.Delete(invalidNotifications); // we delete notifications that could not be migrated for some reason
        }
示例#12
0
        public int?Div(int?v1, int?v2)
        {
            if (!v1.HasValue || !v2.HasValue)
            {
                return(null);
            }

            if (v1.Value >= int.MaxValue || v2.Value >= int.MaxValue)
            {
                return(null);
            }

            if (v1 < v2)
            {
                return(null);
            }

            if (v2 == 0)
            {
                return(null);
            }

            if (v1 % v2 != 0)
            {
                return(null);
            }

            var result = v1 / v2;

            var dbResult = _sqlRepository.Delete();

            if (dbResult == 0)
            {
                return(null);
            }

            return(result);
        }
示例#13
0
 public virtual void Remove(Guid userId, Guid entityId)
 {
     _likesRepository.Delete(like => like.EntityId == entityId && like.UserId == userId);
 }
示例#14
0
 public void Remove(Guid groupId, Guid memberId)
 {
     _groupMemberRepository.Delete(IsGroupAndUserMatch(memberId, groupId));
     _memberCacheService.UpdateMemberCache(memberId);
 }
示例#15
0
 public void Delete(GroupDocument document)
 {
     _repository.Delete(document);
 }
示例#16
0
 public void Delete(Guid id)
 {
     _sqlRepository.Delete(id);
 }
示例#17
0
 public void RemoveRelation(Guid groupId, Guid activityId)
 {
     _groupActivityRepository.Delete(r => r.ActivityId.Equals(activityId) && r.GroupId.Equals(groupId));
 }
示例#18
0
 public void DeleteVacationById(Guid id)
 {
     _vacationRepository.Delete(id);
 }
示例#19
0
 public virtual void Unsubscribe(Guid userId, Guid activityId)
 {
     _subscribeRepository.Delete(s => s.UserId == userId && s.ActivityId == activityId);
 }
示例#20
0
 public void Delete(Guid entityId)
 {
     _sqlRepository.Delete(m => m.EntityId == entityId);
 }
示例#21
0
 public void Delete(Guid id)
 {
     _myLinksRepository.Delete(id);
 }
示例#22
0
 public virtual void Delete(Guid activityId)
 {
     _activitySubscribeSettingRepository.Delete(setting => setting.ActivityId == activityId);
 }
示例#23
0
 public override void Remove(Guid groupId, Guid memberId)
 {
     _groupMemberRepository.Delete(gm => gm.GroupId == groupId && gm.MemberId == memberId);
     _memberCacheService.UpdateMemberCache(memberId);
 }