Exemplo n.º 1
0
        public ICharacterFriendlyTeamModel Create(ICharacterFriendlyTeamModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateIDIsNull(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Search for an Existing Record (Don't allow Duplicates
            var results = Search(CharacterFriendlyTeamMapper.MapToSearchModel(model));

            if (results.Any())
            {
                return(results.First());
            }                                              // Return the first that matches
            // Map model to a new entity
            var newEntity = CharacterFriendlyTeamMapper.MapToEntity(model);

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            CharacterFriendlyTeamsRepository.Add(newEntity);
            // Try to Save Changes
            CharacterFriendlyTeamsRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
Exemplo n.º 2
0
        public void Verify_MapToSearchModel_AssignsCharacterFriendlyTeamSearchProperties()
        {
            // Arrange
            var mapper = new CharacterFriendlyTeamMapper();
            var model  = CharacterFriendlyTeamsMockingSetup.DoMockingSetupForCharacterFriendlyTeamModel();
            // Act
            var searchModel = mapper.MapToSearchModel(model.Object);

            // Assert
            Assert.Equal(model.Object.CharacterId, searchModel.CharacterId);
            Assert.Equal(model.Object.Character?.CustomKey, searchModel.CharacterCustomKey);
            Assert.Equal(model.Object.Character?.ApiDetailUrl, searchModel.CharacterApiDetailUrl);
            Assert.Equal(model.Object.Character?.SiteDetailUrl, searchModel.CharacterSiteDetailUrl);
            Assert.Equal(model.Object.Character?.Name, searchModel.CharacterName);
            Assert.Equal(model.Object.Character?.ShortDescription, searchModel.CharacterShortDescription);
            Assert.Equal(model.Object.Character?.Description, searchModel.CharacterDescription);
            Assert.Equal(model.Object.FriendlyTeamId, searchModel.FriendlyTeamId);
            Assert.Equal(model.Object.FriendlyTeam?.CustomKey, searchModel.FriendlyTeamCustomKey);
            Assert.Equal(model.Object.FriendlyTeam?.ApiDetailUrl, searchModel.FriendlyTeamApiDetailUrl);
            Assert.Equal(model.Object.FriendlyTeam?.SiteDetailUrl, searchModel.FriendlyTeamSiteDetailUrl);
            Assert.Equal(model.Object.FriendlyTeam?.Name, searchModel.FriendlyTeamName);
            Assert.Equal(model.Object.FriendlyTeam?.ShortDescription, searchModel.FriendlyTeamShortDescription);
            Assert.Equal(model.Object.FriendlyTeam?.Description, searchModel.FriendlyTeamDescription);
        }
 public void Verify_MapToSearchModel_AssignsCharacterFriendlyTeamSearchProperties()
 {
     // Arrange
     var mapper = new CharacterFriendlyTeamMapper();
     var model = CharacterFriendlyTeamsMockingSetup.DoMockingSetupForCharacterFriendlyTeamModel();
     // Act
     var searchModel = mapper.MapToSearchModel(model.Object);
     // Assert
     Assert.Equal(model.Object.CharacterId, searchModel.CharacterId);
     Assert.Equal(model.Object.Character?.CustomKey, searchModel.CharacterCustomKey);
     Assert.Equal(model.Object.Character?.ApiDetailUrl, searchModel.CharacterApiDetailUrl);
     Assert.Equal(model.Object.Character?.SiteDetailUrl, searchModel.CharacterSiteDetailUrl);
     Assert.Equal(model.Object.Character?.Name, searchModel.CharacterName);
     Assert.Equal(model.Object.Character?.ShortDescription, searchModel.CharacterShortDescription);
     Assert.Equal(model.Object.Character?.Description, searchModel.CharacterDescription);
     Assert.Equal(model.Object.FriendlyTeamId, searchModel.FriendlyTeamId);
     Assert.Equal(model.Object.FriendlyTeam?.CustomKey, searchModel.FriendlyTeamCustomKey);
     Assert.Equal(model.Object.FriendlyTeam?.ApiDetailUrl, searchModel.FriendlyTeamApiDetailUrl);
     Assert.Equal(model.Object.FriendlyTeam?.SiteDetailUrl, searchModel.FriendlyTeamSiteDetailUrl);
     Assert.Equal(model.Object.FriendlyTeam?.Name, searchModel.FriendlyTeamName);
     Assert.Equal(model.Object.FriendlyTeam?.ShortDescription, searchModel.FriendlyTeamShortDescription);
     Assert.Equal(model.Object.FriendlyTeam?.Description, searchModel.FriendlyTeamDescription);
 }