Exemplo n.º 1
0
        public IVideoTypeModel Create(IVideoTypeModel 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(VideoTypeMapper.MapToSearchModel(model));

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

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