Ejemplo n.º 1
0
        public void Init(long[] entitiesIds)
        {
            var socialUserInfos = _userService.GetUsers(entitiesIds);

            if (socialUserInfos.IsNullOrEmpty())
            {
                return;
            }

            var entities = _entitiesRepository.GetEntitiesByIds(socialUserInfos.Select(x => x.id).ToArray())
                           .ToArray();

            var initilizers = socialUserInfos.Except(socialUserInfos.Join(entities, z => z.id, e => e.OriginalId, (z, e) => z));

            // TODO: we need to find a way to do this in one batch
            foreach (var entity in initilizers)
            {
                _entitiesRepository.Update(new Entity {
                    Id            = ObjectId.GenerateNewId(),
                    OriginalId    = entity.id,
                    Name          = entity.name,
                    ImageUrl      = entity.imageUrl,
                    OriginalEmail = entity.email
                });
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Implementation of <see cref="IEntityMashService.AddVote(Entity)"/>
        /// </summary>
        /// <param name="entity"></param>
        public void AddVote(string identifier)
        {
            var entity = entitiesRepository_.Entities.SingleOrDefault(e => e.Identifier == identifier);

            entity.Votes++;
            entitiesRepository_.Update(entity);
        }
Ejemplo n.º 3
0
 public void Update(ProjectModel project)
 {
     using (_repository = _getRepository())
     {
         ProjectModel toUpdate = _repository.Get(item => item.Id == project.Id).First();
         toUpdate.Name = project.Name;
         _repository.Update(toUpdate);
         _repository.Save();
     }
 }
Ejemplo n.º 4
0
 public void SetSalt(int userId, string salt)
 {
     using (_repository = _getRepository())
     {
         MembershipModel membership = _repository.Get(userId);
         membership.PasswordSalt = salt;
         _repository.Update(membership);
         _repository.Save();
     }
 }
Ejemplo n.º 5
0
        public async Task <ShardData> UpdateDataAsync(ShardData data)
        {
            data.ShardType = data.GetType().Name;
            switch (data)
            {
            case User t1:
                throw new Exception();

            //return await _users.Upda(t1);
            case BotKey t1:
                return(await _entitiesRepository.Update(e => e.Id == data.Id, t1));

            case GlobalValue t1:
                return(await _entitiesRepository.Update(e => e.Id == data.Id, t1));

            case Workflow t1:
                return(await _entitiesRepository.Update(e => e.Id == data.Id, t1));

            case Step t1:
                return(await _entitiesRepository.Update(e => e.Id == data.Id, t1));

            case ExecutionTemplate t1:
                return(await _entitiesRepository.Update(e => e.Id == data.Id, t1));

            case ExecutionSchedule t1:
                return(await _entitiesRepository.Update(e => e.Id == data.Id, t1));
            }
            throw new Exception("Object type " + data.ShardType + " has no supported update operations");
        }
Ejemplo n.º 6
0
 public void Update(SlotModel slot)
 {
     using (_repository = _getRepository())
     {
         SlotModel toUpdate = _repository.Get(item => item.Id == slot.Id).First();
         toUpdate.Name = slot.Name;
         toUpdate.StartDate = slot.StartDate;
         toUpdate.FinishDate = slot.FinishDate;
         toUpdate.TaskId = slot.TaskId;
         _repository.Update(toUpdate);
         _repository.Save();
     }
 }
Ejemplo n.º 7
0
 public void Update(UserModel user)
 {
     using (_repository = _getRepository())
     {
         UserModel toUpdate = _repository.Get(item => item.UserId == user.UserId, item => item.webpages_Roles).First();
         toUpdate.UserName = user.UserName;
         int roleId = user.webpages_Roles.First().RoleId;
         toUpdate.webpages_Roles.Clear();
         toUpdate.webpages_Roles.Add(
             _repository.GetAnother<Model.RoleModel>(item => item.RoleId == roleId).First()
         );
         _repository.Update(toUpdate);
         _repository.Save();
     }
 }
Ejemplo n.º 8
0
        public void UpdateEntityOfflineToken(ObjectId id)
        {
            // TODO : Extract to other places, we might want to use it
            var entity = _entitiesRepository.Get(id);

            if (!string.IsNullOrWhiteSpace(entity.PlatformOfflineToken))
            {
                return;
            }

            var offlineToken = _authService.GetOfflineToken(entity.OriginalId);

            entity.PlatformOfflineToken = offlineToken;

            _entitiesRepository.Update(entity);
        }
Ejemplo n.º 9
0
        public Entity GetEntityFromPlatform()
        {
            var originalEntity = _userService.CurrentUser();

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

            var entity = _entitiesRepository.GetEntitiesByIds(new[] { originalEntity.id }).FirstOrDefault();

            if (entity != null)
            {
                entity.ImageUrl      = originalEntity.imageUrl;
                entity.Name          = originalEntity.name;
                entity.OriginalEmail = entity.OriginalEmail;
                entity.LastActivity  = SystemTime.Now();

                _entitiesRepository.Update(entity);

                return(entity);
            }

            entity = new Entity
            {
                Id            = ObjectId.GenerateNewId(),
                OriginalId    = originalEntity.id,
                Name          = originalEntity.name,
                ImageUrl      = originalEntity.imageUrl,
                OriginalEmail = originalEntity.email,
                LastActivity  = SystemTime.Now(),
                MemberSince   = SystemTime.Now()
            };

            _entitiesRepository.Add(entity);

            return(entity);
        }
Ejemplo n.º 10
0
 public void UpdateCreated(UserModel user)
 {
     using (_repository = _getRepository())
     {
         UserModel toUpdate = _repository.Get(item => item.UserName.Equals(user.UserName)).First();
         int roleId = user.webpages_Roles.First().RoleId;
         toUpdate.webpages_Roles = new []
             {
                 _repository.GetAnother<Model.RoleModel>(item => item.RoleId == roleId).First()
             };
         _repository.Update(toUpdate);
         _repository.Save();
     }
 }
 public void UpdateMembership(Models.webpages_Membership toUpdate)
 {
     using (_membershipRepository = _membershipRepositoryInitializer())
     {
         _membershipRepository.Update(Mapper.Map<Models.webpages_Membership, webpages_Membership>(toUpdate));
         _membershipRepository.Save();
     }
 }
 public bool Update(EntityModel model)
 {
     return(_repository.Update(model));
 }
Ejemplo n.º 13
0
 public void Update(TaskModel task)
 {
     using (_repository = _getRepository())
     {
         TaskModel toUpdate = _repository.Get(item => item.Id == task.Id).First();
         toUpdate.Name = task.Name;
         toUpdate.Description = task.Description;
         toUpdate.TimeEstimate = task.TimeEstimate;
         toUpdate.StartDate = task.StartDate;
         toUpdate.FinishDate = task.FinishDate;
         toUpdate.Filepath = task.Filepath;
         toUpdate.Version = task.Version;
         toUpdate.ProjectId = task.ProjectId;
         toUpdate.AssignedPersonId = task.AssignedPersonId;
         toUpdate.AssigningPersonId = task.AssigningPersonId;
         toUpdate.CategoryId = task.CategoryId;
         toUpdate.StatusId = task.StatusId;
         toUpdate.PriorityId = task.PriorityId;
         toUpdate.TypeId = task.TypeId;
         _repository.Update(toUpdate);
         _repository.Save();
     }
 }