Exemple #1
0
 public static void MapDtoToEntityForUpdating(ResourceRateModifierDto rateModifierDto, ResourceRateModifier rateModifier)
 {
     rateModifier.IsActive    = rateModifierDto.IsActive;
     rateModifier.Name        = rateModifierDto.Name;
     rateModifier.Value       = rateModifierDto.Value;
     rateModifier.ShiftTypeId = rateModifierDto.ShiftTypeId;
     rateModifier.ResourceId  = rateModifierDto.ResourceId;
 }
Exemple #2
0
        // CRUD
        public void Create(ResourceRateModifierDto rateModifierDto, long userId)
        {
            var rateModifier = Mapper.Map <ResourceRateModifier>(rateModifierDto);

            _unitOfWork.ResourceRateModifierRepository.Create(rateModifier);
            _unitOfWork.Save();

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeCreate,
                AppConstants.ResourceRateModifierTableName,
                userId,
                rateModifier.Id);
        }
Exemple #3
0
        public void Update(ResourceRateModifierDto rateModifierDto, long userId)
        {
            var rateModifier = _unitOfWork.ResourceRateModifierRepository.GetById(rateModifierDto.Id);

            CommonHelperAppService.MapDtoToEntityForUpdating(rateModifierDto, rateModifier);

            _unitOfWork.ResourceRateModifierRepository.Update(rateModifier);
            _unitOfWork.Save();

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeUpdate,
                AppConstants.ResourceRateModifierTableName,
                userId,
                rateModifier.Id);
        }
        public void Should_Map_ResourceRateModifierDto_to_ResourceRateModifier()
        {
            // Arrange
            var _mModifier = new Mock <ResourceRateModifier>();

            var modifierDto = new ResourceRateModifierDto
            {
                IsActive    = true,
                Name        = _testNameString,
                Value       = 10.9,
                ResourceId  = 1,
                ShiftTypeId = 1
            };

            // Act
            CommonHelperAppService.MapDtoToEntityForUpdating(modifierDto, _mModifier.Object);

            // Assert
            Assert.AreEqual(modifierDto.IsActive, _mModifier.Object.IsActive);
            Assert.AreEqual(modifierDto.Name, _mModifier.Object.Name);
            Assert.AreEqual(modifierDto.Value, _mModifier.Object.Value);
            Assert.AreEqual(modifierDto.ResourceId, _mModifier.Object.ResourceId);
            Assert.AreEqual(modifierDto.ShiftTypeId, _mModifier.Object.ShiftTypeId);
        }