Ejemplo n.º 1
0
        public ILocationAliasModel Create(ILocationAliasModel 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(LocationAliasMapper.MapToSearchModel(model));

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

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            LocationAliasesRepository.Add(newEntity);
            // Try to Save Changes
            LocationAliasesRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
Ejemplo n.º 2
0
        public void Verify_MapToSearchModel_AssignsLocationAliasSearchProperties()
        {
            // Arrange
            var mapper = new LocationAliasMapper();
            var model  = LocationAliasesMockingSetup.DoMockingSetupForLocationAliasModel();
            // Act
            var searchModel = mapper.MapToSearchModel(model.Object);

            // Assert
            Assert.Equal(model.Object.LocationId, searchModel.LocationId);
            Assert.Equal(model.Object.Location?.CustomKey, searchModel.LocationCustomKey);
            Assert.Equal(model.Object.Location?.ApiDetailUrl, searchModel.LocationApiDetailUrl);
            Assert.Equal(model.Object.Location?.SiteDetailUrl, searchModel.LocationSiteDetailUrl);
            Assert.Equal(model.Object.Location?.Name, searchModel.LocationName);
            Assert.Equal(model.Object.Location?.ShortDescription, searchModel.LocationShortDescription);
            Assert.Equal(model.Object.Location?.Description, searchModel.LocationDescription);
        }
 public void Verify_MapToSearchModel_AssignsLocationAliasSearchProperties()
 {
     // Arrange
     var mapper = new LocationAliasMapper();
     var model = LocationAliasesMockingSetup.DoMockingSetupForLocationAliasModel();
     // Act
     var searchModel = mapper.MapToSearchModel(model.Object);
     // Assert
     Assert.Equal(model.Object.LocationId, searchModel.LocationId);
     Assert.Equal(model.Object.Location?.CustomKey, searchModel.LocationCustomKey);
     Assert.Equal(model.Object.Location?.ApiDetailUrl, searchModel.LocationApiDetailUrl);
     Assert.Equal(model.Object.Location?.SiteDetailUrl, searchModel.LocationSiteDetailUrl);
     Assert.Equal(model.Object.Location?.Name, searchModel.LocationName);
     Assert.Equal(model.Object.Location?.ShortDescription, searchModel.LocationShortDescription);
     Assert.Equal(model.Object.Location?.Description, searchModel.LocationDescription);
 }