コード例 #1
0
        public TreasuryDto Update(TreasuryUpdateDto dto)
        {
            TreasuryDto treasuryDto = null;

            try
            {
                var treasury = _unitOfWork.GenericRepository <Treasury>().GetById(dto.Id);

                _unitOfWork.CreateTransaction();

                foreach (var treasuryCashDto in dto.TreasuryCashes)
                {
                    _treasuryCashAppService.Update(treasuryCashDto);
                }


                //treasury.ModifiedBy = _appSession.GetUserName();
                treasury.Name = dto.Name;

                _unitOfWork.GenericRepository <Treasury>().Update(treasury);
                _unitOfWork.Save();

                _unitOfWork.Commit();
                _unitOfWork.GenericRepository <Treasury>().RefershEntity(treasury);
                treasuryDto = Mapper.Map <Treasury, TreasuryDto>(treasury);
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
                _unitOfWork.Rollback();
            }
            return(treasuryDto);
        }
コード例 #2
0
        public TreasuryUpdateDto GetForEdit(int id)
        {
            TreasuryUpdateDto treasuryDto = null;

            try
            {
                var treasury = _unitOfWork.GenericRepository <Treasury>().GetById(id);
                if (treasury != null)
                {
                    treasuryDto = Mapper.Map <Treasury, TreasuryUpdateDto>(treasury);
                }
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
            }

            return(treasuryDto);
        }