Exemplo n.º 1
0
        public Task <ClientCashDto> InsertAsync(ClientCashDto dto)
        {
            return(Task.Factory.StartNew(() => {
                ClientCashDto clientCashDto = null;
                try
                {
                    var clientCash = Mapper.Map <ClientCashDto, ClientCash>(dto);
                    clientCash.CreatedBy = _appSession.GetUserName();
                    clientCash.IsEnabled = true;
                    _unitOfWork.CreateTransaction();

                    _unitOfWork.GenericRepository <ClientCash>().Insert(clientCash);
                    _unitOfWork.Save();

                    _unitOfWork.Commit();

                    clientCashDto = Mapper.Map <ClientCash, ClientCashDto>(clientCash);
                }
                catch (Exception ex)
                {
                    Tracing.SaveException(ex);
                    _unitOfWork.Rollback();
                }
                return clientCashDto;
            }));
        }
Exemplo n.º 2
0
        public ClientCashDto GetById(int id)
        {
            ClientCashDto clientCashDto = null;

            try
            {
                var clientCash = _unitOfWork.GenericRepository <ClientCash>().GetById(id);
                if (clientCash != null)
                {
                    clientCashDto = Mapper.Map <ClientCash, ClientCashDto>(clientCash);
                }
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
            }

            return(clientCashDto);
        }
Exemplo n.º 3
0
        public ClientCashDto UpdateBalance(ClientCashesDto dto)
        {
            ClientCashDto clientCashDto = null;

            try
            {
                var clientCash = _unitOfWork.GenericRepository <ClientCash>().GetById(dto.Id);
                Mapper.Map <ClientCashesDto, ClientCash>(dto, clientCash);
                clientCash.ModifiedBy = _appSession.GetUserName();

                _unitOfWork.GenericRepository <ClientCash>().Update(clientCash);
                _unitOfWork.Save();

                clientCashDto = Mapper.Map <ClientCash, ClientCashDto>(clientCash);
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
            }
            return(clientCashDto);
        }