Exemplo n.º 1
0
        private List <CharacterChoices> GetAllCharacters()
        {
            List <CharacterChoices> characters = null;

            FileIoStatus = FileIoMessage.None;
            try
            {
                using (CharacterRepo cRepo = new CharacterRepo())
                {
                    characters = cRepo.GetAll() as List <CharacterChoices>;
                };
                if (characters != null)
                {
                    FileIoStatus = FileIoMessage.Complete;
                }
                else
                {
                    FileIoStatus = FileIoMessage.NoRecordsFound;
                }
            }
            catch (Exception)
            {
                FileIoStatus = FileIoMessage.FileAccessError;
            }
            return(characters);
        }
Exemplo n.º 2
0
        private CharacterChoices GetCharacter(int id)
        {
            CharacterChoices character = null;

            FileIoStatus = FileIoMessage.None;
            try
            {
                using (CharacterRepo cRepo = new CharacterRepo())
                {
                    character = cRepo.GetById(id);
                };
                if (character != null)
                {
                    FileIoStatus = FileIoMessage.Complete;
                }
                else
                {
                    FileIoStatus = FileIoMessage.RecordNotFound;
                }
            }
            catch (Exception)
            {
                FileIoStatus = FileIoMessage.FileAccessError;
            }
            return(character);
        }
Exemplo n.º 3
0
 public void AddCharacter(CharacterChoices character)
 {
     try
     {
         if (character != null)
         {
             using (CharacterRepo cRepo = new CharacterRepo())
             {
                 cRepo.Add(character);
             };
             FileIoStatus = FileIoMessage.Complete;
         }
     }
     catch (Exception)
     {
         FileIoStatus = FileIoMessage.FileAccessError;
     }
 }
Exemplo n.º 4
0
 public void DeleteCharacter(int id)
 {
     try
     {
         if (GetCharacter(id) != null)
         {
             using (CharacterRepo cRepo = new CharacterRepo())
             {
                 cRepo.Delete(id);
             }
             FileIoStatus = FileIoMessage.Complete;
         }
     }
     catch (Exception)
     {
         FileIoStatus = FileIoMessage.FileAccessError;
     }
 }
Exemplo n.º 5
0
 public void UpdateCharacter(CharacterChoices updatedCharacter)
 {
     try
     {
         if (GetCharacter(updatedCharacter.Id) != null)
         {
             using (CharacterRepo cRepo = new CharacterRepo())
             {
                 cRepo.Update(updatedCharacter);
             }
             FileIoStatus = FileIoMessage.Complete;
         }
         else
         {
             FileIoStatus = FileIoMessage.RecordNotFound;
         }
     }
     catch (Exception)
     {
         FileIoStatus = FileIoMessage.FileAccessError;
     }
 }