public IList <CompanyCashesDto> GetCompanyCashes(int companyId) { IList <CompanyCashesDto> companyBalanceDtos = new List <CompanyCashesDto>(); try { var companyCashs = _unitOfWork.GenericRepository <CompanyCash>().FindBy(x => x.CompanyId == companyId).ToList(); foreach (var companyCash in companyCashs) { var companyBalanceDto = new CompanyCashesDto() { Id = companyCash.Id, CoinId = companyCash.CoinId, CoinName = companyCash.Coin != null ? companyCash.Coin.Name : string.Empty, CompanyId = companyCash.CompanyId, InitialBalance = companyCash.InitialBalance, Total = companyCash.Total, MaxCreditor = companyCash.MaxCreditor, MaxDebit = companyCash.MaxDebit }; decimal onHim = 0; decimal forHim = 0; if (companyBalanceDto.Total > 0) { forHim = (companyBalanceDto.Total * 100) / 100; } else if (companyBalanceDto.Total < 0) { onHim = (companyBalanceDto.Total * 100) / 100; } companyBalanceDto.ForHim = forHim; companyBalanceDto.OnHim = onHim; companyBalanceDtos.Add(companyBalanceDto); } } catch (Exception ex) { Tracing.SaveException(ex); } return(companyBalanceDtos); }
public CompanyCashDto UpdateBalance(CompanyCashesDto dto) { CompanyCashDto companyCashDto = null; try { var companyCash = _unitOfWork.GenericRepository <CompanyCash>().GetById(dto.Id); Mapper.Map <CompanyCashesDto, CompanyCash>(dto, companyCash); companyCash.ModifiedBy = _appSession.GetUserName(); //_unitOfWork.CreateTransaction(); _unitOfWork.GenericRepository <CompanyCash>().Update(companyCash); _unitOfWork.Save(); //_unitOfWork.Commit(); companyCashDto = Mapper.Map <CompanyCash, CompanyCashDto>(companyCash); } catch (Exception ex) { Tracing.SaveException(ex); } return(companyCashDto); }