public IPowerModel Create(IPowerModel 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(PowerMapper.MapToSearchModel(model)); if (results.Any()) { return(results.First()); } // Return the first that matches // Map model to a new entity var newEntity = PowerMapper.MapToEntity(model); newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime; newEntity.UpdatedDate = null; newEntity.Active = true; // Add it PowersRepository.Add(newEntity); // Try to Save Changes PowersRepository.SaveChanges(); // Return the new value return(Get(newEntity.Id)); }
public void Verify_MapToSearchModel_AssignsPowerSearchProperties() { // Arrange var mapper = new PowerMapper(); var model = PowersMockingSetup.DoMockingSetupForPowerModel(); // Act var searchModel = mapper.MapToSearchModel(model.Object); // Assert }
public void Verify_MapToSearchModel_AssignsPowerSearchProperties() { // Arrange var mapper = new PowerMapper(); var model = PowersMockingSetup.DoMockingSetupForPowerModel(); // Act var searchModel = mapper.MapToSearchModel(model.Object); // Assert }