Exemple #1
0
        public ActionResult Details(int id)
        {
            try
            {
                //Check Authentication
                if (Session["user"] == null)
                {
                    return(RedirectToAction("Index", "Login"));
                }
                //Object Initiliaze
                ListingModel model       = new ListingModel();
                Listings     lstdetails  = new Listings();
                listing      objlisting  = new listing();
                Features     objfeatures = new Features();
                Buildings    objBuilding = new Buildings();
                List <ListingFeaturesControl> lstListingFeaturesControl = new List <ListingFeaturesControl>();
                BuildingFeatures objbuildingfeatures = new BuildingFeatures();
                List <feature>   lstfeat             = new List <feature>();
                objlisting = lstdetails.GetListing(id);

                //Start performing the logic section
                List <buildingfeature> newobjBuildingFeatures = objbuildingfeatures.GetBuildingFeature(objlisting.buildingid);
                foreach (var item in newobjBuildingFeatures)
                {
                    feature objfeat = objfeatures.GetFeatureById(item.id);
                    lstfeat.Add(objfeat);
                }
                foreach (var item in lstfeat)
                {
                    ListingFeaturesControl objListFeat = new ListingFeaturesControl();
                    if (string.IsNullOrEmpty(Convert.ToString(objListFeat)))
                    {
                        objListFeat.features_name = item.features_name;
                        objListFeat.id            = item.id;
                        lstListingFeaturesControl.Add(objListFeat);
                    }
                }
                var building = objBuilding.GetBuilding(objlisting.buildingid);
                model.BuildingName  = building.Name;
                model.Features      = lstListingFeaturesControl;
                model.Address       = objlisting.address;
                model.id            = objlisting.id;
                model.Price         = Convert.ToInt32(objlisting.price);
                model.PropertyType  = objlisting.propertytype;
                model.Layout        = objlisting.layout;
                model.Bathroom      = objlisting.bathroom;
                model.Sqft          = objlisting.sqft;
                model.property_type = objlisting.property_type;
                if (objlisting.property_type == "Residential")
                {
                    model.res_type_str = objlisting.res_type;
                }
                else
                {
                    model.com_type_str = objlisting.com_type;
                }
                model.OwnershipType    = objlisting.ownershiptype;
                model.UnitNumber       = objlisting.unitnumber;
                model.FloorNumber      = objlisting.floornumber;
                model.createdAt        = (DateTime)objlisting.createddate;
                model.PetPolicyListstr = objlisting.petpolicy;
                model.Minleaseterm     = objlisting.minleaseterm;
                model.DateAvailable    = (DateTime)objlisting.dateavailable;
                ListingUploads getObjListingUpload = new ListingUploads();

                var filename = getObjListingUpload.GetListingUploadById(objlisting.id, "PHOTOS").Select(t => t.image).FirstOrDefault();
                if (!string.IsNullOrEmpty(filename))
                {
                    var filenamestr = filename.Split('\\');
                    ViewBag.PhotosList = filenamestr[6];
                }
                else
                {
                    ViewBag.PhotosList = "Desert.jpg";
                }
                ViewBag.PhotoCount = getObjListingUpload.GetListingUploadById(objlisting.id, "PHOTOS").Count.ToString();
                return(View(model));
            }
            catch (Exception ex)
            {
                //handling exception
                throw ex;
            }
        }