예제 #1
0
 public static void MapDtoToEntityForUpdating(SubSiteDto subSiteDto, SubSite subSite)
 {
     subSite.IsActive      = subSiteDto.IsActive;
     subSite.Name          = subSiteDto.Name;
     subSite.SiteId        = subSiteDto.SiteId;
     subSite.SubSiteTypeId = subSiteDto.SubSiteTypeId;
 }
        // CRUD
        public void Create(SubSiteDto subSiteDto, long userId)
        {
            var subSite = Mapper.Map <SubSite>(subSiteDto);

            _unitOfWork.SubSiteRepository.Create(subSite);
            _unitOfWork.Save();

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeCreate,
                AppConstants.SubSiteTableName,
                userId,
                subSite.Id);
        }
        public void Update(SubSiteDto subSiteDto, long userId)
        {
            var subSite = _unitOfWork.SubSiteRepository.GetById(subSiteDto.Id);

            CommonHelperAppService.MapDtoToEntityForUpdating(subSiteDto, subSite);

            _unitOfWork.SubSiteRepository.Update(subSite);
            _unitOfWork.Save();

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeUpdate,
                AppConstants.SubSiteTableName,
                userId,
                subSite.Id);
        }
        public void SHould_Map_SubSiteDto_to_SubSite()
        {
            // Arrange
            var _mSubSite = new Mock <SubSite>();

            var subSiteDto = new SubSiteDto
            {
                IsActive      = true,
                Name          = _testNameString,
                SiteId        = 1,
                SubSiteTypeId = 1
            };

            // Act
            CommonHelperAppService.MapDtoToEntityForUpdating(subSiteDto, _mSubSite.Object);

            // Assert
            Assert.AreEqual(subSiteDto.IsActive, _mSubSite.Object.IsActive);
            Assert.AreEqual(subSiteDto.Name, _mSubSite.Object.Name);
            Assert.AreEqual(subSiteDto.SiteId, _mSubSite.Object.SiteId);
            Assert.AreEqual(subSiteDto.SubSiteTypeId, _mSubSite.Object.SubSiteTypeId);
        }