public static SupervisorMembershipEntity Create(ISupervisorMembership src)
            {
                var entity = new SupervisorMembershipEntity
                {
                    PartitionKey = GeneratePartitionKey(src.MerchantId),
                    RowKey       = GenerateRowKey(src.EmployeeId)
                };

                return(Mapper.Map(src, entity));
            }
        public async Task <ISupervisorMembership> AddAsync(ISupervisorMembership src)
        {
            SupervisorMembershipEntity entity = SupervisorMembershipEntity.ByMerchant.Create(src);

            await _tableStorage.InsertThrowConflict(entity);

            AzureIndex index = SupervisorMembershipEntity.IndexByEmployee.Create(entity);

            await _employeeIndexStorage.InsertThrowConflict(index);

            return(Mapper.Map <Core.Domain.SupervisorMembership.SupervisorMembership>(entity));
        }
        public async Task UpdateAsync(ISupervisorMembership src)
        {
            SupervisorMembershipEntity updatedEntity = await _tableStorage.MergeAsync(
                SupervisorMembershipEntity.ByMerchant.GeneratePartitionKey(src.MerchantId),
                SupervisorMembershipEntity.ByMerchant.GenerateRowKey(src.EmployeeId),
                entity =>
            {
                if (src.MerchantGroups.Any())
                {
                    entity.MerchantGroups = string.Join(Constants.Separator, src.MerchantGroups);
                }

                return(entity);
            });

            if (updatedEntity == null)
            {
                throw new KeyNotFoundException();
            }
        }
 public static AzureIndex Create(SupervisorMembershipEntity membershipEntity)
 {
     return(AzureIndex.Create(
                GeneratePartitionKey(membershipEntity.EmployeeId),
                GenerateRowKey(), membershipEntity));
 }