public bool IsSatisfiedBy(Entities.CulturalExchange entity)
        {
            Entities.CollegeTime collegeTime = _collegeTimeRepository.GetById(entity.CollegeTimeId);

            if (entity.WeekNumber == 25 && !entity.Renew)
            {
                var sumValueWithPercentage = (double)collegeTime.NetPrice + ((double)collegeTime.NetPrice * collegeTime.PercentagePrice) / 100;

                if (sumValueWithPercentage >= (double)entity.TotalValue)
                {
                    entity.ValidationResult.Add(new ValidationResult("Course value incorrect"));
                }
            }
            else if (entity.Renew)
            {
                if (collegeTime.RenewPrice > (decimal)entity.TotalValue)
                {
                    entity.ValidationResult.Add(new ValidationResult("Course value incorrect"));
                }

                entity.ArrivalDateTime = null;
                entity.FlightNumber    = null;
                entity.Company         = null;
            }

            return(false);
        }
        public List <CulturalExchange> GetAll(Guid idEnvironment, bool active)
        {
            var culturalExchangeEntity = _culturalExchangeRepository
                                         .FindByFilter(x => x.Environment.Id == idEnvironment && x.Available == active);

            culturalExchangeEntity.ForEach(x =>
            {
                x.College = _collegeRepository.GetById(x.CollegeId);

                if (x.AccomodationId.HasValue)
                {
                    x.Accomodation = _accomodationRepository.GetById(x.AccomodationId.Value);
                }

                x.Student     = _studentRepository.GetById(x.StudentId);
                x.CollegeTime = _collegeTimeRepository.GetById(x.CollegeTimeId);
            });

            return(culturalExchangeEntity);
        }
Ejemplo n.º 3
0
        public Accomodation GetAccomodationAndCulturalExchangeList(Guid id)
        {
            var accomodation = _accomodationRepository.GetAccomodationAndCulturalExchangeList(id);

            accomodation.CulturalExchanges.ForEach(ce =>
            {
                ce.Student     = _studentRepository.GetById(ce.StudentId);
                ce.CollegeTime = _collegeTimeRepository.GetById(ce.CollegeTimeId);
                ce.College     = _collegeRepository.GetById(ce.CollegeId);
            });

            return(accomodation);
        }
 public CollegeTime GetById(Guid id)
 {
     return(_collegeTimeRepository.GetById(id));
 }