Beispiel #1
0
        public List <GoForCheckOrRedirectDTO> GetProviderActionCheckorRedirect()
        {
            var result = _db.GoForCheckOrRedirects.ToList();

            List <GoForCheckOrRedirectDTO> goForChecksOrRedirectList = new List <GoForCheckOrRedirectDTO>();

            foreach (var item in result)
            {
                EmergencyPropertyDTO emergencyProperty = new EmergencyPropertyDTO();
                EmergencyHelper(item.Id, item.PropertyId, item.PropertyType, out emergencyProperty);

                goForChecksOrRedirectList.Add(new GoForCheckOrRedirectDTO {
                    Id               = emergencyProperty.Id,
                    Name             = emergencyProperty.Name,
                    FirmName         = emergencyProperty.FirmName,
                    Price            = emergencyProperty.Price,
                    PropertyLocation = emergencyProperty.PropertyLocation,
                    PropertyType     = emergencyProperty.PropertyType,
                    FirmLocation     = emergencyProperty.FirmLocation,
                    FirmAction       = item.FirmAction.ToString(),
                    PropertyId       = item.PropertyId,
                    DateCreated      = item.DateCreated.ToShortDateString()
                });
            }

            return(goForChecksOrRedirectList);
        }
Beispiel #2
0
        public List <EmergencyPropertyDTO> GetEmergencyProperties()
        {
            var result = _db.EmergencyProperties.ToList();

            List <EmergencyPropertyDTO> emergencyList = new List <EmergencyPropertyDTO>();

            foreach (var item in result)
            {
                EmergencyPropertyDTO emergencyProperty = new EmergencyPropertyDTO();
                EmergencyHelper(item.Id, item.PropertyId, item.PropertyType, out emergencyProperty);

                emergencyList.Add(emergencyProperty);
            }

            return(emergencyList);
        }
Beispiel #3
0
        public void EmergencyHelper(int id, int propertyId, PropertyType propertyType, out EmergencyPropertyDTO emergencyProperty)
        {
            emergencyProperty = new EmergencyPropertyDTO();
            switch (propertyType)
            {
            case PropertyType.Rental:
                var property = _db.RentalProperties.Include(m => m.Firm)
                               .FirstOrDefault(m => m.Id == propertyId);
                emergencyProperty = new EmergencyPropertyDTO {
                    Name             = property.Name,
                    Price            = property.Price,
                    PropertyId       = property.Id,
                    PropertyLocation = property.Town + "," + property.City + "," + property.State,
                    FirmName         = property.Firm.Name,
                    FirmLocation     = property.Firm.Location,
                    PropertyType     = propertyType.ToString(),
                    Id = id
                };
                break;

            case PropertyType.OnSale:
                var onsale = _db.OnSaleProperties.Include(m => m.Firm)
                             .FirstOrDefault(m => m.Id == propertyId);
                emergencyProperty = new EmergencyPropertyDTO {
                    Name             = onsale.Name,
                    Price            = onsale.Price,
                    PropertyId       = onsale.Id,
                    PropertyLocation = onsale.Town + "," + onsale.City + "," + onsale.State,
                    FirmName         = onsale.Firm.Name,
                    FirmLocation     = onsale.Firm.Location,
                    PropertyType     = propertyType.ToString(),
                    Id = id
                };
                break;

            case PropertyType.Commercial:
                var commercial = _db.CommercialProperties.Include(m => m.Firm)
                                 .FirstOrDefault(m => m.Id == propertyId);
                emergencyProperty = new EmergencyPropertyDTO {
                    Name             = commercial.Name,
                    Price            = commercial.Price,
                    PropertyId       = commercial.Id,
                    PropertyLocation = commercial.Town + "," + commercial.City + "," + commercial.State,
                    FirmName         = commercial.Firm.Name,
                    FirmLocation     = commercial.Firm.Location,
                    PropertyType     = propertyType.ToString(),
                    Id = id
                };
                break;

            case PropertyType.LandProperty:
                var land = _db.LandProperties.Include(m => m.Firm)
                           .FirstOrDefault(m => m.Id == propertyId);
                emergencyProperty = new EmergencyPropertyDTO {
                    Name             = land.Name,
                    Price            = land.Price,
                    PropertyId       = land.Id,
                    PropertyLocation = land.Town + "," + land.City + "," + land.State,
                    FirmName         = land.Firm.Name,
                    FirmLocation     = land.Firm.Location,
                    PropertyType     = propertyType.ToString(),
                    Id = id
                };
                break;
            }
        }