public CulturalExchange GetById(Guid id)
        {
            var culturalExchangeEntity = _culturalExchangeRepository.GetById(id);

            culturalExchangeEntity.CollegeTime  = _collegeTimeRepository.GetById(culturalExchangeEntity.CollegeTimeId);
            culturalExchangeEntity.College      = _collegeRepository.GetById(culturalExchangeEntity.CollegeId);
            culturalExchangeEntity.Accomodation = culturalExchangeEntity.AccomodationId.HasValue ? _accomodationRepository.GetById(culturalExchangeEntity.AccomodationId.Value) : null;
            culturalExchangeEntity.Student      = _studentRepository.GetById(culturalExchangeEntity.StudentId);
            culturalExchangeEntity.CulturalExchangeFileUpload = _culturalExchangeFileUploadRepository.GetAllByCulturalExchangeId(id);

            return(culturalExchangeEntity);
        }
Exemple #2
0
        public bool IsSatisfiedBy(Entities.ReceivePaymentCulturalExchange entity)
        {
            var payments         = _receivePaymentCulturalExchangeRepository.FindByFilter(x => x.CulturalExchangeId == entity.CulturalExchangeId);
            var culturalExchange = _culturalExchangeRepository.GetById(entity.CulturalExchangeId);

            var lastTotalPayments = payments.Sum(x => x.Value) - culturalExchange.TotalValue;

            if (lastTotalPayments == 0)
            {
                return(true);
            }

            return(false);
        }
        public bool IsSatisfiedBy(Entities.ReceivePaymentCulturalExchange entity)
        {
            var payments         = _receivePaymentCulturalExchangeRepository.FindByFilter(x => x.CulturalExchangeId == entity.CulturalExchangeId);
            var culturalExchange = _culturalExchangeRepository.GetById(entity.CulturalExchangeId);

            var sumTotalPayments = payments.Sum(x => x.Value);

            var sumTotalIncludedNewPayment = sumTotalPayments + entity.Value;

            if (sumTotalIncludedNewPayment > culturalExchange.TotalValue)
            {
                entity.ValidationResult.Add(new ValidationResult("Values incorrects"));
            }

            return(true);
        }