public ActionResult EditProperty(int id, PropertyTypeClassifier type) { PropertyViewOperation p = new PropertyViewOperation(); if (type == PropertyTypeClassifier.Apartament) { ApartmentModel model = p.GetPropertyApartment(id); return View("~/Views/Property/Submit.cshtml", model); } else if (type == PropertyTypeClassifier.House) { HouseModel model = p.GetPropertyHouse(id); return View("~/Views/Property/Submit.cshtml", model); } else if (type == PropertyTypeClassifier.Commercial) { CommercialModel model = p.GetPropertyCommercial(id); return View("~/Views/Property/Submit.cshtml", model); } else { LandModel model= p.GetPropertyLand(id); return View("~/Views/Property/Submit.cshtml", model); } }
public ActionResult SubmitCommercial(CommercialModel model, HttpPostedFileBase[] files) { if (files.Length == 1 && files[0] == null && !model.HasImage) { ModelState.AddModelError(string.Empty, "A photo file must be chosen."); } if (ModelState.IsValid) { PhotoProcessing(files, model); CommercialOperation operation = new CommercialOperation(); var result = operation.Execute(model, User.Identity.GetUserId()); if (result.IsSuccess) return RedirectToAction("Index"); } return View("Submit", model); }
public CommercialModel GetPropertyCommercial(int id) { CommercialModel model = new CommercialModel(); using (PMSContext db = new PMSContext()) { var dbmodel = db.Properties.FirstOrDefault(x => x.PropertyId == id); model.PropertyType = (PropertyTypeClassifier)dbmodel.TypeId; model.PropertyStatus = (PropertyStatusClassifier)dbmodel.SellingCondition; model.PropertyId = dbmodel.PropertyId; model.Price = dbmodel.Price; //addresss model.PropertyDescription = dbmodel.PropertyDescription; var addressModel = db.PropertyAddresses.FirstOrDefault(x => x.PropertyAddressId == dbmodel.PropertyAddressId); model.City = addressModel.CityId; model.District = addressModel.DistrictId; model.Metro = addressModel.MetroId; model.AddressDescription = addressModel.Description; //photo model.Photos = new List <PhotoModel>(); foreach (var d in db.Photos.Where(x => x.PropertyId == dbmodel.PropertyId)) { model.Photos.Add(new PhotoModel { PhotoPath = d.PhotoPath }); } //apart model.FloorNumberCommercial = (int)dbmodel.FloorNumber; model.TotalAreaCommercial = dbmodel.TotalArea; model.RoomNumberCommercial = (int)dbmodel.RoomNumber; model.HasImage = true; //feature var ft = db.PropertyFeatures.Where(x => x.PropertyId == dbmodel.PropertyId); foreach (var f in ft) { var fea = db.Features.FirstOrDefault(x => x.FeatureId == f.FeatureId); if (fea.FeatureTitle == "Credit") { model.CreditCommercial = true; } if (fea.FeatureTitle == "HasDocument") { model.HasDocumentCommercial = true; } if (fea.FeatureTitle == "Repairing") { model.RepairingCommercial = true; } if (fea.FeatureTitle == "Gas") { model.GasCommercial = true; } if (fea.FeatureTitle == "Water") { model.WaterCommercial = true; } if (fea.FeatureTitle == "Electric") { model.ElectricCommercial = true; } if (fea.FeatureTitle == "Telephone") { model.TelephoneCommercial = true; } if (fea.FeatureTitle == "CabelTV") { model.CabelTVCommercial = true; } if (fea.FeatureTitle == "Internet") { model.InternetCommercial = true; } if (fea.FeatureTitle == "Conditioner") { model.ConditionerCommercial = true; } if (fea.FeatureTitle == "Handy") { model.HandyCommercial = true; } if (fea.FeatureTitle == "CombySystem") { model.CombySystemCommercial = true; } } } Repository rep = new Repository(); model.DistrictList = rep.GetDistricts(model.City); model.MetroList = rep.GetMetroes(model.City); return(model); }