Пример #1
0
        public bool UpdateEditionCountry(int editionCountryId, EditionCountryEntity editionCountryEntity, int userId)
        {
            var success = false;

            if (editionCountryEntity != null)
            {
                var editionCountry = _unitOfWork.EditionCountryRepository.GetById(editionCountryId);
                if (editionCountry != null)
                {
                    // TODO:
                    //Mapper.CreateMap<EditionCountryEntity, EditionCountry>()
                    //    .ForMember(dest => dest.EditionId, opt => opt.Ignore())
                    //    .ForMember(dest => dest.CreatedOn, opt => opt.Ignore())
                    //    .ForMember(dest => dest.CreatedBy, opt => opt.Ignore());
                    // TODO: Mapping overrides the values of the properties which are unintended to be mapped.
                    //Mapper.Map(editionCountryEntity, editionCountry);
                    editionCountry.CountryCode  = editionCountryEntity.CountryCode;
                    editionCountry.RelationType = (byte)editionCountryEntity.RelationType;
                    editionCountry.UpdatedOn    = DateTime.Now;
                    editionCountry.UpdatedBy    = userId;

                    _unitOfWork.EditionCountryRepository.Update(editionCountry);
                    _unitOfWork.Save();
                    success = true;
                }
            }
            return(success);
        }
Пример #2
0
        public int CreateEditionCountry(EditionCountryEntity editionCountryEntity, int userId)
        {
            // TODO:
            //Mapper.CreateMap<EditionCountryEntity, EditionCountry>()
            //    .ForMember(dest => dest.EditionId, src => src.MapFrom(x => x.EditionId))
            //    .ForMember(dest => dest.UpdatedOn, opt => opt.Ignore())
            //    .ForMember(dest => dest.UpdatedBy, opt => opt.Ignore());
            //var editionCountry = Mapper.Map<EditionCountryEntity, EditionCountry>(editionCountryEntity);
            var editionCountry = new EditionCountry
            {
                EditionId    = editionCountryEntity.EditionId,
                CountryCode  = editionCountryEntity.CountryCode,
                RelationType = (byte)editionCountryEntity.RelationType,
                CreatedOn    = DateTime.Now,
                CreatedBy    = userId
            };

            _unitOfWork.EditionCountryRepository.Insert(editionCountry);
            _unitOfWork.Save();
            return(editionCountry.EditionCountryId);
        }