コード例 #1
0
        public CompanyCountryDto Update(CompanyCountryDto dto)
        {
            CompanyCountryDto companyCountryDto = null;

            try
            {
                var companyCountry = _unitOfWork.GenericRepository <CompanyCountry>().GetById(dto.Id);
                Mapper.Map <CompanyCountryDto, CompanyCountry>(dto, companyCountry);
                companyCountry.ModifiedBy = _appSession.GetUserName();
                //_unitOfWork.CreateTransaction();

                _unitOfWork.GenericRepository <CompanyCountry>().Update(companyCountry);
                _unitOfWork.Save();

                //_unitOfWork.Commit();

                companyCountryDto = Mapper.Map <CompanyCountry, CompanyCountryDto>(companyCountry);
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
                //_unitOfWork.Rollback();
            }
            return(companyCountryDto);
        }
コード例 #2
0
        public CompanyCountryDto Insert(CompanyCountryDto dto)
        {
            CompanyCountryDto companyCountryDto = null;

            try
            {
                var companyCountry = Mapper.Map <CompanyCountryDto, CompanyCountry>(dto);
                companyCountry.CreatedBy = _appSession.GetUserName();
                companyCountry.IsEnabled = true;

                _unitOfWork.CreateTransaction();

                _unitOfWork.GenericRepository <CompanyCountry>().Insert(companyCountry);
                _unitOfWork.Save();

                _unitOfWork.Commit();

                companyCountryDto = Mapper.Map <CompanyCountry, CompanyCountryDto>(companyCountry);
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
                _unitOfWork.Rollback();
            }
            return(companyCountryDto);
        }