public Participation PushAllocationIntoParticipation(Allocation allocation) { IParticipationRepository participationRepository = _DataRepositoryFactory.GetDataRepository <IParticipationRepository>(); IFundRepository fundRepository = _DataRepositoryFactory.GetDataRepository <IFundRepository>(); Participation participation = participationRepository.GetParticipationsByAccount(allocation.Reservation.AccountID) .Where(p => p.FundID == allocation.FundID) .FirstOrDefault(); try { if (participation == null) { if (CanFundAcceptNewParticipation(allocation.FundID, allocation.Amount)) { participation = new Participation() { AccountID = allocation.Reservation.AccountID, InitialBalance = allocation.Amount, Fund = fundRepository.Get(allocation.FundID) }; participationRepository.Add(participation); } } else { if (CanFundAcceptParticipationAddition(participation.Fund.FundID, allocation.Amount)) { participation.CurrentBalance += allocation.Amount; } participationRepository.Update(participation); } allocation.Pushed = true; } catch (Exception e) { } return(participation); }
public Participation[] GetParticipationsByAccount(string loginEmail) { return(ExecuteFaultHandledOperation(() => { IAccountRepository accountRepository = _DataRepositoryFactory.GetDataRepository <IAccountRepository>(); IParticipationRepository ParticipationRepository = _DataRepositoryFactory.GetDataRepository <IParticipationRepository>(); Account account = accountRepository.GetByLogin(loginEmail); if (account == null) { NotFoundFault fault = new NotFoundFault(string.Format("No account found for login '{0}'.", loginEmail)); throw new FaultException <NotFoundFault>(fault, fault.Message); } ValidateAuthorization(account); IEnumerable <Participation> participations = ParticipationRepository.GetParticipationsByAccount(account.AccountID); return participations.ToArray(); })); }