コード例 #1
0
        public BranchCommissionDto Insert(BranchCommissionInsertDto dto)
        {
            BranchCommissionDto branchCommissionDto = null;

            try
            {
                var branchCommission = Mapper.Map <BranchCommissionInsertDto, BranchCommission>(dto);
                branchCommission.CreatedBy = _appSession.GetUserName();
                branchCommission.IsEnabled = true;
                _unitOfWork.CreateTransaction();

                var branch = _unitOfWork.GenericRepository <Domain.Model.Branches.Branch>().GetAll().FirstOrDefault();
                branchCommission.BranchId = branch.Id;

                _unitOfWork.GenericRepository <BranchCommission>().Insert(branchCommission);
                _unitOfWork.Save();

                _unitOfWork.Commit();

                branchCommissionDto = Mapper.Map <BranchCommission, BranchCommissionDto>(branchCommission);
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
                _unitOfWork.Rollback();
            }
            return(branchCommissionDto);
        }
コード例 #2
0
        public BranchCommissionDto GetById(int id)
        {
            BranchCommissionDto branchCommissionDto = null;

            try
            {
                var branchCommission = _unitOfWork.GenericRepository <BranchCommission>().GetById(id);
                if (branchCommission != null)
                {
                    branchCommissionDto = Mapper.Map <BranchCommission, BranchCommissionDto>(branchCommission);
                }
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
            }

            return(branchCommissionDto);
        }
コード例 #3
0
        public BranchCommissionDto Update(BranchCommissionUpdateDto dto)
        {
            BranchCommissionDto branchCommissionDto = null;

            try
            {
                var branchCommission = _unitOfWork.GenericRepository <BranchCommission>().GetById(dto.Id);
                Mapper.Map <BranchCommissionUpdateDto, BranchCommission>(dto, branchCommission);
                branchCommission.ModifiedBy = _appSession.GetUserName();
                _unitOfWork.CreateTransaction();

                _unitOfWork.GenericRepository <BranchCommission>().Update(branchCommission);
                _unitOfWork.Save();

                _unitOfWork.Commit();

                branchCommissionDto = Mapper.Map <BranchCommission, BranchCommissionDto>(branchCommission);
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
            }
            return(branchCommissionDto);
        }