// CRUD public void Create(ShiftTypeDto shiftTypeDto, long userId) { var shiftType = Mapper.Map <ShiftType>(shiftTypeDto); _unitOfWork.ShiftTypeRepository.Create(shiftType); _unitOfWork.Save(); // Audit _auditLogAppService.Audit( AppConstants.ActionTypeCreate, AppConstants.ShiftTypeTableName, userId, shiftType.Id); }
public void Update(ShiftTypeDto shiftTypeDto, long userId) { var shiftType = _unitOfWork.ShiftTypeRepository.GetById(shiftTypeDto.Id); CommonHelperAppService.MapDtoToEntityForUpdating(shiftTypeDto, shiftType); _unitOfWork.ShiftTypeRepository.Update(shiftType); _unitOfWork.Save(); // Audit _auditLogAppService.Audit( AppConstants.ActionTypeUpdate, AppConstants.ShiftTypeTableName, userId, shiftType.Id); }
public void Should_Map_ShiftTypeDto_to_ShiftType() { // Arrange var _mShiftType = new Mock <ShiftType>(); var shiftTypeDto = new ShiftTypeDto { IsActive = true, Name = _testNameString }; // Act CommonHelperAppService.MapDtoToEntityForUpdating(shiftTypeDto, _mShiftType.Object); // Assert Assert.AreEqual(shiftTypeDto.IsActive, _mShiftType.Object.IsActive); Assert.AreEqual(shiftTypeDto.Name, _mShiftType.Object.Name); }
public static void MapDtoToEntityForUpdating(ShiftTypeDto shiftTypeDto, ShiftType shiftType) { shiftType.IsActive = shiftTypeDto.IsActive; shiftType.Name = shiftTypeDto.Name; shiftType.IsOvernight = shiftTypeDto.IsOvernight; }