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