Пример #1
0
        /// <summary>
        /// Gets a single character by ID
        /// </summary>
        /// <param name="characterId">Id of character</param>
        /// <returns>HTTP response with character view model object</returns>
        public HttpResponseMessage Get(int characterId)
        {
            Character c = characterRepro.GetCharacter(characterId);

            CharacterViewModel character = ModelConverter.ToCharacterViewModel(c);

            return(Request.CreateResponse(HttpStatusCode.OK, character));
        }
Пример #2
0
        public IEnumerable <ICharacter> GetCharacter(string[] characterIds, IResolverContext context)

        {
            foreach (string characterId in characterIds)

            {
                ICharacter character = _repository.GetCharacter(characterId);

                if (character == null)

                {
                    context.ReportError(

                        "Could not resolve a charachter for the " +

                        $"character-id {characterId}.");
                }

                else

                {
                    yield return(character);
                }
            }
        }
 public IEnumerable <ICharacter> GetCharacter(
     [Parent] ICharacter character,
     [Service] CharacterRepository repository)
 {
     foreach (string friendId in character.Friends)
     {
         ICharacter friend = repository.GetCharacter(friendId);
         if (friend != null)
         {
             yield return(friend);
         }
     }
 }
        public void DeleteCalendar_ShouldRemoveFromCharacter()
        {
            var characterRepository = new CharacterRepository();
            var deletedCalendar     = CreateAndRetrieveCalendar();
            var notDeletedCalendar  = CreateAndRetrieveCalendar();

            var dto = CreateCharacterUtil.GetNewCharacterDetails(testLibrary.LibraryId);

            dto.CalendarId = deletedCalendar.CalendarId;
            var characterId = characterRepository.CreateCharacter(dto);

            dto.CalendarId = notDeletedCalendar.CalendarId;
            var character2Id = characterRepository.CreateCharacter(dto);

            repository.DeleteCalendar(deletedCalendar.CalendarId);

            var character  = characterRepository.GetCharacter(characterId);
            var character2 = characterRepository.GetCharacter(character2Id);

            Assert.AreEqual(DatabaseConstants.DEFAULT_ID, character.CalendarId);
            Assert.AreEqual(notDeletedCalendar.CalendarId, character2.CalendarId);
        }
Пример #5
0
 public Human GetOtherHuman(
     [Parent] ICharacter character,
     [Service] CharacterRepository repository)
 {
     if (character.Friends.Count == 0)
     {
         return(null);
     }
     return(character.Friends
            .Select(t => repository.GetCharacter(t))
            .OfType <Human>()
            .FirstOrDefault());
 }
Пример #6
0
 public IEnumerable <ICharacter> GetCharacter(string[] characterIds)
 {
     foreach (string characterId in characterIds)
     {
         ICharacter character = _repository.GetCharacter(characterId);
         if (character == null)
         {
             throw new Exception("Not found");
         }
         else
         {
             yield return(character);
         }
     }
 }
Пример #7
0
        public static IEnumerable <ICharacter> GetCharacter(
            IResolverContext context)
        {
            ICharacter          character  = context.Parent <ICharacter>();
            CharacterRepository repository = context.Service <CharacterRepository>();

            foreach (string friendId in character.Friends)
            {
                ICharacter friend = repository.GetCharacter(friendId);
                if (friend != null)
                {
                    yield return(friend);
                }
            }
        }
Пример #8
0
 public IEnumerable <ICharacter> GetCharacter(string[] characterIds)
 {
     foreach (string characterId in characterIds)
     {
         ICharacter character = _repository.GetCharacter(characterId);
         if (character == null)
         {
             throw new Exception(
                       "Could not resolve a character for the " +
                       $"character-id {characterId}.");
         }
         else
         {
             yield return(character);
         }
     }
 }
Пример #9
0
        private Character CreateAndRetrieveCharacter(CreateCharacterDto dto)
        {
            var characterId = characterRepository.CreateCharacter(dto);

            return(characterRepository.GetCharacter(characterId));
        }
Пример #10
0
 public Character GetCharacter(long characterId)
 {
     return(characterRepository.GetCharacter(characterId));
 }