Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public GeoDivisionService(MyDbContext context)
 {
     _context         = context;
     _currentCurrency = CurrencyHelper.GetCurrencyId();
     _currentLang     = LanguageHelper.GetCulture();
 }
Exemplo n.º 3
0
 public RealStateService(MyDbContext context)
 {
     _context         = context;
     _currentCurrency = CurrencyHelper.GetCurrencyId();
     _currentLang     = LanguageHelper.GetCulture();
 }