예제 #1
0
        public ActionResult Add(ListingModel model)
        {
            try
            {
                //Check Authentication
                if (Session["user"] == null)
                {
                    return(RedirectToAction("Index", "Login"));
                }
                //Object Initiliaze
                listing        _listing        = new listing();
                Buildings      _building       = new Buildings();
                Listings       listings        = new Listings();
                listingupload  _listinguploads = new listingupload();
                ListingUploads listinguploads  = new ListingUploads();

                //Start performing the logic section
                var building = _building.GetBuilding(model.BuildingId);
                _listing.address              = building.address;
                _listing.propertytype         = Convert.ToString(model.PropertyType);
                _listing.ownershiptype        = Convert.ToString(model.OwnershipType);
                _listing.unitnumber           = model.UnitNumber;
                _listing.floornumber          = model.FloorNumber;
                _listing.layout               = Convert.ToString(model.LayoutList);
                _listing.bathroom             = Convert.ToString(model.BathroomList);
                _listing.sqft                 = model.Sqft;
                _listing.price                = model.Price;
                _listing.dateavailable        = model.DateAvailable;
                _listing.minleaseterm         = model.Minleaseterm;
                _listing.maxleaseterm         = model.Maxleaseterm;
                _listing.furnished            = Convert.ToString(model.FurnishedList);
                _listing.furnishedamount      = Convert.ToDecimal(model.FurnishedAmount);
                _listing.feestructure         = Convert.ToString(model.Feestructure);
                _listing.incentives           = Convert.ToString(model.IncentivesList);
                _listing.renterpays           = model.Renterpays;
                _listing.commissionpercentage = model.CommissionPercentage;
                _listing.cobrokesplit         = model.Cobrokesplit;
                _listing.exclusivetype        = Convert.ToString(model.ExclusiveTypeList);
                if (model.Exclusiveagreement != null)
                {
                    var file = model.Exclusiveagreement;
                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var path     = Path.Combine(Server.MapPath("~/images/ExecutiveAgreement/"), fileName);
                        file.SaveAs(path);
                        _listing.exclusiveagreement = path;
                    }
                }
                _listing.petpolicy                 = Convert.ToString(model.PetPolicyList);
                _listing.unitcondition             = Convert.ToString(model.UnitConditionList);
                _listing.unitview                  = Convert.ToString(model.UnitViewList);
                _listing.unitexposure              = Convert.ToString(model.UnitExposure);
                _listing.publicunitdescription     = model.PublicUnitDescription;
                _listing.brokerviewinginstructions = model.BrokerViewingInstructions;
                _listing.occupancystatus           = Convert.ToString(model.OccupancyStatusList);
                _listing.firstshowingdate          = model.FirstShowingDate;
                _listing.keyinoffice               = model.KeyInOffice;
                _listing.keydetails                = model.KeyDetails;
                _listing.privateunitnotes          = model.PrivateUnitNotes;
                _listing.listingprivate            = model.ListingPrivate;
                _listing.managementid              = 2;
                _listing.createddate               = DateTime.Now;
                _listing.updateddate               = DateTime.Now;
                _listing.isactive                  = true;
                _listing.status              = 1;
                _listing.buildingid          = model.BuildingId;
                _listing.sales_price         = model.sales_price;
                _listing.sales_date          = model.sales_date;
                _listing.sales_cc_main_fee   = model.sales_cc_main_fee;
                _listing.sales_monthly_tax   = model.sales_monthly_tax;
                _listing.sales_comm_struct   = model.sales_comm_struct;
                _listing.sales_tax_deduction = model.sales_tax_deduction;
                _listing.sales_flip_tax      = model.sales_flip_tax;
                _listing.sales_max_fin       = model.sales_max_fin;
                _listing.sales_exe_type      = Convert.ToString(model.sales_exe_type);
                _listing.property_type       = model.property_type;
                if (model.property_type == "Residential")
                {
                    _listing.res_type = Convert.ToString(model.res_type);
                }
                else
                {
                    _listing.com_type = Convert.ToString(model.com_type);
                }
                _listing.com_sqft          = model.com_sqft;
                _listing.com_electric_cost = model.com_electric_cost;
                _listing.com_lease_type    = Convert.ToString(model.com_lease_type);
                _listing.is_divide         = model.is_divide;
                _listing.is_food_ok        = model.is_food_ok;
                _listing.is_vented         = model.is_vented;
                _listing.listing_type      = model.listing_type;
                if (model.PhotoUploadList.Count > 0)
                {
                    _listing.has_photos = true;
                }
                else
                {
                    _listing.has_photos = false;
                }
                if (model.FloorUploadList.Count > 0)
                {
                    _listing.has_floorplans = true;
                }
                else
                {
                    _listing.has_floorplans = false;
                }

                int Id = listings.AddListing(_listing, model.AgentList);

                if (model.PhotoUploadList.Count > 0)
                {
                    foreach (HttpPostedFileBase photofile in model.PhotoUploadList)
                    {
                        if (photofile != null && photofile.ContentLength > 0)
                        {
                            var fileName = Path.GetFileName(photofile.FileName);
                            var path     = Path.Combine(Server.MapPath("~/images/Photos/"), fileName);
                            photofile.SaveAs(path);
                            _listinguploads.image     = path;
                            _listinguploads.type      = "PHOTOS";
                            _listinguploads.listingid = Id;
                            listinguploads.AddListingUploads(_listinguploads);
                        }
                    }
                }
                if (model.FloorUploadList.Count > 0)
                {
                    foreach (HttpPostedFileBase floorfile in model.FloorUploadList)
                    {
                        if (floorfile != null && floorfile.ContentLength > 0)
                        {
                            var fileName = Path.GetFileName(floorfile.FileName);
                            var path     = Path.Combine(Server.MapPath("~/images/FloorPlans/"), fileName);
                            floorfile.SaveAs(path);
                            _listinguploads.image     = path;
                            _listinguploads.type      = "FLOORPLANS";
                            _listinguploads.listingid = Id;
                            listinguploads.AddListingUploads(_listinguploads);
                        }
                    }
                }
                if (model.BuildingFeaturesList.Count > 0)
                {
                    BuildingFeatures buildingFeatures = new BuildingFeatures();
                    foreach (var item in model.BuildingFeaturesList)
                    {
                        buildingfeature newBuildingFeature = new buildingfeature();
                        newBuildingFeature.buildingid = model.BuildingId;
                        newBuildingFeature.featuresid = item.id;
                        buildingFeatures.AddBuildingFeatures(newBuildingFeature);
                    }
                }
                if (model.OpenHouseList.Count > 0)
                {
                    OpenHouses objOpenHouses = new OpenHouses();
                    foreach (var item in model.OpenHouseList)
                    {
                        openhous newOpenHous = new openhous();
                        newOpenHous.appoinmentonly = item.IsAppointmentOnly;
                        newOpenHous.brokeronly     = item.IsBrokerOnly;
                        newOpenHous.date           = item.openhousedate;
                        newOpenHous.endtime        = item.openhouseendtime;
                        newOpenHous.starttime      = item.openhousestarttime;
                        newOpenHous.repeat         = Convert.ToString(item.RepeatId);
                        newOpenHous.listingid      = Id;
                        objOpenHouses.AddOpenHouse(newOpenHous);
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                //handling exception
                throw ex;
            }
        }
예제 #2
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;
            }
        }