Exemple #1
0
        public HttpResponseMessage GetPropertyByID([FromUri] int PropertyId)
        {
            try
            {
                if (PropertyId != 0)
                {
                    var Property = _PropertyService.GetProperty(PropertyId);
                    Mapper.CreateMap <CommunicationApp.Entity.Property, CommunicationApp.Web.Models.PropertyModel>();
                    CommunicationApp.Web.Models.PropertyModel PropertyModel = Mapper.Map <CommunicationApp.Entity.Property, CommunicationApp.Web.Models.PropertyModel>(Property);
                    var PropertyImages = _PropertyImageService.GetPropertyImages().Where(c => c.PropertyId == PropertyId);
                    List <PropertyImages> PropertyImageList = new List <PropertyImages>();
                    foreach (var propertyImage in PropertyImages)
                    {
                        PropertyImages PropertyImage = new PropertyImages();
                        PropertyImage.imagelist = propertyImage.ImagePath;
                        PropertyImageList.Add(PropertyImage);
                    }

                    PropertyModel.PropertyPhotolist = PropertyImageList;
                    var Customer = _CustomerService.GetCustomer(Convert.ToInt32(Property.CustomerId));
                    PropertyModel.CustomerName  = Customer.FirstName;
                    PropertyModel.CustomerPhoto = Customer.PhotoPath;
                    return(Request.CreateResponse(HttpStatusCode.OK, Common.CreateMessage("success", PropertyModel), Configuration.Formatters.JsonFormatter));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, Common.CreateMessage("error", "Property id null."), Configuration.Formatters.JsonFormatter));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, Common.CreateMessage("error", "Property not found."), Configuration.Formatters.JsonFormatter));
            }
        }
Exemple #2
0
        public List <PropertyModel> GetPropertyList(List <Entity.Property> Properties)
        {
            List <PropertyModel> PropertyModelList = new List <PropertyModel>();

            Mapper.CreateMap <CommunicationApp.Entity.Property, CommunicationApp.Web.Models.PropertyModel>();
            foreach (var Property in Properties)
            {
                CommunicationApp.Web.Models.PropertyModel Propertymodel = Mapper.Map <CommunicationApp.Entity.Property, CommunicationApp.Web.Models.PropertyModel>(Property);
                var PropertyImages = _PropertyImageService.GetPropertyImages().Where(c => c.PropertyId == Property.PropertyId).ToList();


                // passing 'SaleOfBusinessType' to return model according to PropertyType.
                if (Property.PropertyStatusId != null)
                {
                    if (Property.PropertyStatusId == (int)EnumValue.PropertySatus.ExclusiveCommercial)
                    {
                        Propertymodel.TypeOfProperty = EnumValue.GetEnumDescription(EnumValue.PropertySatus.ExclusiveCommercial);
                    }
                    else if (Property.PropertyStatusId == (int)EnumValue.PropertySatus.ExclusiveResidential)
                    {
                        Propertymodel.TypeOfProperty = EnumValue.GetEnumDescription(EnumValue.PropertySatus.ExclusiveResidential);
                    }
                    else if (Property.PropertyStatusId == (int)EnumValue.PropertySatus.ExclusiveResidentialCondo)
                    {
                        Propertymodel.TypeOfProperty = EnumValue.GetEnumDescription(EnumValue.PropertySatus.ExclusiveResidentialCondo);
                    }
                    else if (Property.PropertyStatusId == (int)EnumValue.PropertySatus.LookingForCommercial)
                    {
                        Propertymodel.TypeOfProperty = EnumValue.GetEnumDescription(EnumValue.PropertySatus.LookingForCommercial);
                    }
                    else if (Property.PropertyStatusId == (int)EnumValue.PropertySatus.LookingForResidential)
                    {
                        Propertymodel.TypeOfProperty = EnumValue.GetEnumDescription(EnumValue.PropertySatus.LookingForResidential);
                    }
                    else if (Property.PropertyStatusId == (int)EnumValue.PropertySatus.LookingForResidentialCondo)
                    {
                        Propertymodel.TypeOfProperty = EnumValue.GetEnumDescription(EnumValue.PropertySatus.LookingForResidentialCondo);
                    }
                    else if (Property.PropertyStatusId == (int)EnumValue.PropertySatus.NewHotListingCommercial)
                    {
                        Propertymodel.TypeOfProperty = EnumValue.GetEnumDescription(EnumValue.PropertySatus.NewHotListingCommercial);
                    }
                    else if (Property.PropertyStatusId == (int)EnumValue.PropertySatus.NewHotListingResidential)
                    {
                        Propertymodel.TypeOfProperty = EnumValue.GetEnumDescription(EnumValue.PropertySatus.NewHotListingResidential);
                    }
                    else if (Property.PropertyStatusId == (int)EnumValue.PropertySatus.NewHotListingResidentialCondo)
                    {
                        Propertymodel.TypeOfProperty = EnumValue.GetEnumDescription(EnumValue.PropertySatus.NewHotListingResidentialCondo);
                    }
                }
                List <PropertyImages> PropertyImagesList = new List <PropertyImages>();
                foreach (var PropertyImage in PropertyImages)
                {
                    PropertyImages PropertyImg = new PropertyImages();
                    PropertyImg.imagelist = PropertyImage.ImagePath;
                    PropertyImagesList.Add(PropertyImg);
                }
                Propertymodel.PropertyPhotolist = PropertyImagesList;
                var customer = _CustomerService.GetCustomer(Convert.ToInt32(Property.CustomerId));
                Propertymodel.CustomerName   = customer.FirstName;
                Propertymodel.CustomerTrebId = customer.TrebId;
                Propertymodel.CustomerPhoto  = customer.PhotoPath;
                PropertyModelList.Add(Propertymodel);
            }

            return(PropertyModelList.ToList());
        }