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); }
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); }