// GET: Admin/RealStates/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RealState realState = _realStateRepo.Get(id.Value); if (realState == null) { return(HttpNotFound()); } var selectedCity = _geoDivisionRepo.Get(realState.GeoDivisionId); var selectedState = _geoDivisionRepo.GetGeoDivisionParent(selectedCity.ParentId.Value); var selectedCountry = _geoDivisionRepo.GetGeoDivisionParent(selectedState.ParentId.Value); ViewBag.SelectedState = selectedState.Id; ViewBag.SelectedCountry = selectedCountry.Id; ViewBag.States = _geoDivisionRepo.GetGeoDivisionChildren(selectedCountry.Id); ViewBag.Cities = _geoDivisionRepo.GetGeoDivisionChildren(selectedState.Id); ViewBag.Countries = _geoDivisionRepo.GetCountries(); return(View(realState)); }
public RealStateDetailDto GetRealStateDetail(int id) { var model = new RealStateDetailDto(); var lang = LanguageHelper.GetCulture(); var _realStateRepos = new RealStatesRepository(_context, new LogsRepository(_context)); var _geoDivisionsRepo = new GeoDivisionsRepository(_context, new LogsRepository(_context)); var _planRepos = new PlansRepository(_context, new LogsRepository(_context)); var _optionRepos = new OptionsRepository(_context, new LogsRepository(_context)); var _realStateGalleryRepos = new RealStateGalleriesRepository(_context, new LogsRepository(_context)); var _commentRepos = new RealStateCommentsRepository(_context, new LogsRepository(_context)); var realState = _realStateRepos.GetRealStateWithNavigations(id); var realStateCity = _geoDivisionsRepo.Get(realState.GeoDivisionId); var realStateState = _geoDivisionsRepo.Get(realStateCity.ParentId.Value); var realStateCountry = _geoDivisionsRepo.GetGeoDivisionParent(realStateState.ParentId.Value); //var planId = 0; if (realState.Plans != null) { //planId = realState.Plans.FirstOrDefault().Id; var plans = _planRepos.GetRealStatePlans(realState.Id); var plan = plans.FirstOrDefault(); //var options = _optionRepos.GetPlanOptions(planId); model.Description = lang == (int)Language.Farsi ? realState.Description : realState.EnglishDescription; model.Region = lang == (int)Language.Farsi ? realState.Region : realState.EnglishRegion; model.Type = realState.Type; //model.Options = options; model.City = realStateCity.Title; model.Country = realStateCountry.Title; model.Id = realState.Id; model.Area = plan.Area; model.Bathroom = plan.BathRooms; model.Bedroom = plan.Rooms; var price = CurrencyHelper.ExchangeAmount(plan.Price, _currentCurrency); var symbol = CurrencyHelper.GetCurrencyUnit(); model.Price = price; model.PriceSymbol = symbol; model.Address = _geoDivisionsRepo.GetFullLocation(lang, realState.GeoDivisionId); model.Title = lang == (int)Language.Farsi ? realState.Title : realState.EnglishTitle; model.ShortDescription = lang == (int)Language.Farsi ? realState.ShortDescription : realState.EnglishShortDescription; model.Image = realState.Image; model.VideoStr = realState.VideoStr; model.Plans = realState.Plans; model.Location = realState.Location; var vm = new List <PlanWithOptionDto>(); foreach (var item in realState.Plans) { var OPT = _optionRepos.GetPlanOptions(item.Id); vm.Add(new PlanWithOptionDto() { Plan = item, Options = OPT }); } model.PlanWithOptions = vm; } model.RealStateGalleriesList = _realStateGalleryRepos.GetRealStateGalleries(id); var comments = _commentRepos.GetRealStateComments(id); model.RealStateCommentList.AddRange(comments); return(model); }