public async Task <ActionResult <AgentAccountDto> > GetAgentForUpdate(int agentId, CancellationToken cancellationToken)
        {
            var user = await ModelService.AsQueryable(i => i.Id == agentId)
                       .Select(i => new AgentAccountDto
            {
                Description = i.Description,
                Email       = i.UserAccount.Email,
                AgentId     = i.Id,
                UserName    = i.UserAccount.UserName,
                HasPublishingAuthorization = i.HasPublishingAuthorization,
                Phone01       = i.UserAccount.Phone01,
                IsResponsible = i.IsResponsible,
                Address01     = i.UserAccount.Address01,
                LastName      = i.UserAccount.LastName,
                ZipCode       = i.UserAccount.ZipCode,
                FirstName     = i.UserAccount.FirstName,
                Phone02       = i.UserAccount.Phone02,
                Address02     = i.UserAccount.Address02,
                MiddleName    = i.UserAccount.MiddleName,
                UserId        = i.UserAccountId
            }).FirstOrDefaultAsync(cancellationToken);

            if (user is null)
            {
                return(NotFound());
            }
            return(user);
        }
        public async Task <ActionResult <IEnumerable <UserAccountDto> > > GetAgents(CancellationToken cancellationToken)
        {
            var agents = await ModelService.AsQueryable(/*a => a.RealEstateId == _userProvider.RealEstateId*/)
                         .Include(i => i.UserAccount)
                         .Select(i => new UserAccountDto
            {
                AgentId = i.Id,
                Id      = i.UserAccountId,
                AuthenticationProviderId          = i.UserAccount.AuthenticationProviderId,
                AuthenticationProviderAccessToken = i.UserAccount.AuthenticationProviderAccessToken,
                UserName    = i.UserAccount.UserName,
                IsActive    = i.UserAccount.IsActive,
                IsConfirmed = i.UserAccount.IsConfirmed,
                HasExternalAuthentication = i.UserAccount.HasExternalAuthentication,
                ActivationKey             = i.UserAccount.ActivationKey,
                ResetPasswordKey          = i.UserAccount.ResetPasswordKey,
                RegistrationDate          = i.UserAccount.RegistrationDate,
                FirstName  = i.UserAccount.FirstName,
                LastName   = i.UserAccount.LastName,
                MiddleName = i.UserAccount.MiddleName,
                Email      = i.UserAccount.Email,
                Phone01    = i.UserAccount.Phone01,
                Phone02    = i.UserAccount.Phone01,
                Address01  = i.UserAccount.Address01,
                Address02  = i.UserAccount.Address01,
                ZipCode    = i.UserAccount.ZipCode,
            }).ToListAsync(cancellationToken);

            agents.ForEach(a => a.PasswordHash = null);

            return(agents);
        }
        public async Task <ActionResult <IEnumerable <PropertyFeatureTranslateDto> > > GetFromTenant(int tenantId, CancellationToken cancellationToken)
        {
            var res = await ModelService.DataConvertQuery(ModelService.AsQueryable(i => i.PropertyFeatureId == tenantId))
                      .ToListAsync(cancellationToken);

            return(res);
        }
Пример #4
0
        public async Task <ActionResult <PageResultDto <RequestStateListDto> > > GetByRequestId(int requestId, CancellationToken cancellationToken)
        {
            //var result = await new PageResultDto<RequestStateListDto>(
            //            ModelService.AsQueryable(r => r.RequestId == requestId)
            //            .Select(p => new RequestStateListDto
            //            {
            //                Id = p.Id,
            //                RequestId = p.RequestId,
            //                WorkflowStepId = p.WorkflowStepId,
            //                WorkflowStep = p.WorkflowStep,
            //                StartStepDate = p.StartStepDate,
            //                FinishedDate = p.FinishedDate,
            //                Description = p.Description,
            //                IsDone = p.IsDone,
            //                AgentId = p.AgentId,
            //            }), new PageRequestDto(100, 1))
            //    .GetPage(cancellationToken);

            var result = await GetPageResultAsync(
                ModelService.AsQueryable(i => i.RequestId == requestId),
                new PageRequestDto(100, 0),
                new NullFilter <RequestState>(), cancellationToken);

            return(result);
        }
Пример #5
0
        public async Task <WebAppUserProfileDto> Profile(CancellationToken cancellationToken)
        {
            var user = await ModelService.AsQueryable(u => u.Id == _userProvider.Id)
                       .Select(u => new WebAppUserProfileDto
            {
                Id                = u.Id,
                LanguageId        = u.Id,
                Email             = u.Email,
                UserName          = u.UserName,
                CountryId         = u.CountryId,
                CountryName       = u.Country == null ? "" : u.Country.Name,
                City              = u.City,
                Address01         = u.Address01,
                Address02         = u.Address02,
                FirstName         = u.FirstName,
                LastName          = u.LastName,
                IsActive          = u.IsActive,
                IsConfirmed       = u.IsConfirmed,
                MiddleName        = u.MiddleName,
                ZipCode           = u.ZipCode,
                VatCode           = u.VatCode,
                Phone01           = u.Phone01,
                Phone02           = u.Phone02,
                RegistrationDate  = u.RegistrationDate,
                UserPicture       = u.UserPicture,
                UserPictureTumblr = u.UserPictureTumblr,
            }).FirstAsync(cancellationToken);

            //user.UserPicture = _pathProvider.GetImageApiPath<UserAccount>(nameof(UserAccount.UserPicture), user.Id.ToString());
            //user.UserPictureTumblr = _pathProvider.GetImageApiPath<UserAccount>(nameof(UserAccount.UserPictureTumblr), user.Id.ToString());
            return(user);
        }
 public async Task <ActionResult <CheckReadyToPublish> > CheckReadyToPublish(int propertyId, CancellationToken cancellationToken)
 {
     return(await ModelService.AsQueryable(r => r.Id == propertyId)
            .Select(r =>
                    new CheckReadyToPublish
     {
         Title = !string.IsNullOrEmpty(r.Title),
         Size = r.PropertyDetail != null,
         Price = r.PropertyPrice != null,
         Media = r.PropertyImage.Any(),
     }).FirstOrDefaultAsync(cancellationToken));
 }
        public override async Task <ActionResult <PageResultDto <RequestListDto> > > GetPageAsync([FromBody] PageRequestFilterDto requestDto, CancellationToken cancellationToken)
        {
            var result = await GetPageResultAsync(
                ModelService.AsQueryable(i => i.AgentId == _userProvider.AgentId),
                requestDto,
                requestDto.Filter.ToObject <RequestListFilter>(),
                cancellationToken);

            //foreach (var item in result.Value.Items)
            //{
            //    if (item.User != null)
            //        item.User.PasswordHash = null;
            //}

            return(result);
        }
        public override async Task <ActionResult <PageResultDto <RequestListDto> > > GetPageAsync(int pageSize, int pageNumber, CancellationToken cancellationToken)
        {
            var result = await GetPageResultAsync(
                ModelService.AsQueryable(i => i.AgentId == _userProvider.AgentId),
                //.Include(r => r.RequestAgent)
                //.Include(r => r.RequestType)
                //.Include(r => r.UserAccountIdRequesterNavigation)
                //.Include(r => r.UserAccountIdSharedNavigation)
                //.Include(r => r.PropertyNavigation)
                //.Include(r => r.RequestState)
                //.Include(r => r.RequestAction)
                //.Include(r => r.Workflow)
                //.Include(r => r.Workflow.WorkflowStep),
                new PageRequestDto(pageSize, pageNumber),
                new NullFilter <Request>(), cancellationToken);

            //foreach (var item in result.Value.Items)
            //{
            //    if (item.User != null)
            //        item.User.PasswordHash = null;
            //}

            return(result);
        }
Пример #9
0
 public async Task <ActionResult <IEnumerable <PropertyFloorPlanDto> > > GetPropertyFloorPlans(int propertyId, CancellationToken cancellationToken)
 => await ModelService.DataConvertQuery(ModelService.AsQueryable(i => i.PropertyId == propertyId)).ToListAsync(cancellationToken);
        public override async Task <ActionResult <RequestDto> > GetAsync(int id, CancellationToken cancellationToken)
        {
            var result = await ModelService.AsQueryable(r => r.Id == id)
                         //.Include(i => i.UserAccountIdRequesterNavigation)
                         .Include(i => i.RequestAgent)
                         .Include(i => i.RequestType)
                         //.Include("RequestAction.RequestActionFollowUp")
                         .Select(i => new RequestDto
            {
                Id            = i.Id,
                Description   = i.Description,
                Title         = i.Title,
                DateCreated   = i.DateCreated,
                RequestTypeId = i.RequestTypeId,
                RequestType   = i.RequestType,
                WorkflowId    = i.WorkflowId,
                Workflow      = i.Workflow != null ? new Workflow
                {
                    Id            = i.Workflow.Id,
                    Name          = i.Workflow.Name,
                    RequestTypeId = i.Workflow.RequestTypeId,
                    RequestType   = i.Workflow.RequestType,
                    Request       = i.Workflow.Request,
                    WorkflowStep  = i.Workflow.WorkflowStep,
                } : null,
                CanAddProperty         = i.RequestType.CanAddProperty,
                UserAccountIdShared    = i.UserAccountIdShared,
                UserAccountShared      = i.UserAccountIdSharedNavigation,
                NetworkIdShared        = i.NetworkIdShared,
                NetworkShared          = i.NetworkIdSharedNavigation,
                TrackingNumber         = i.TrackingNumber,
                UserAccountIdRequester = i.UserAccountIdRequester,
                User = i.UserAccountIdRequesterNavigation,
                RequesterFullname = i.RequesterFullname,
                RequesterEmail    = i.RequesterEmail,
                RequesterPhone    = i.RequesterPhone,
                PropertyId        = i.PropertyId,
                PropertyTitle     = i.PropertyNavigation != null ? i.PropertyNavigation.Title : "",
                AgentId           = i.AgentId,
                Agent             = i.Agent,
                Actions           = i.RequestAction,
                States            = i.RequestState.Select(r => new RequestState
                {
                    Id             = r.Id,
                    RequestId      = r.RequestId,
                    Request        = r.Request,
                    StartStepDate  = r.StartStepDate,
                    FinishedDate   = r.FinishedDate,
                    Description    = r.Description,
                    AgentId        = r.AgentId,
                    Agent          = r.Agent,
                    WorkflowStepId = r.WorkflowStepId,
                    WorkflowStep   = r.WorkflowStep,
                    IsDone         = r.IsDone,
                }),
                IsAssigned = i.AgentId.HasValue,
                Commission = i.Commission,
                IsDone     = i.IsDone,
                IsSuccess  = i.IsSuccess,
            }).FirstOrDefaultAsync();

            return(result);
        }
Пример #11
0
 public async Task <ActionResult <IEnumerable <RequestActionFollowUpDto> > > GetFromTenant(int tenantId, CancellationToken cancellationToken) =>
 await DtoConverter(ModelService.AsQueryable(i => i.RequestActionId == tenantId))
 .ToListAsync(cancellationToken);
        GetWebAppEstate(int propertyId, CancellationToken cancellationToken)
        {
            var propertyPage = await ModelService
                               .AsQueryable(p => p.IsPublished && p.Id == propertyId)
                               .Include(p => p.PropertyPrice)
                               .Include(p => p.PropertyDetail)
                               .Include(p => p.PropertyLocation)
                               .Include(p => p.PropertyInvolveFeature)
                               .Include(p => p.PropertyAdditionalDetail)
                               .Include(p => p.PropertyAttachment)
                               .Select(p => new WebSiteEstateDto
            {
                Id               = p.Id,
                PropertyTypeId   = p.PropertyTypeId,
                PropertyType     = p.PropertyType,
                PropertyLabelId  = p.PropertyLabelId,
                PropertyLabel    = p.PropertyLabel,
                PropertyStatusId = p.PropertyStatusId,
                PropertyStatus   = p.PropertyStatus,
                Title            = p.Title,
                ZipCode          = p.Title,
                Price            = p.PropertyPrice,
                PriceSymbol      = p.PropertyPrice.Currency.Symbol,
                VideoUrl         = p.VideoUrl,
                Description      = p.Description,
                PropertyLocation = p.PropertyLocation,
                PropertyDetail   = p.PropertyDetail,
                PropertyUniqId   = p.PropertyUniqId,
                AgentId          = p.Request.RequestAgent.Any() ?
                                   p.Request.RequestAgent.FirstOrDefault().AgentId : 0,
                PublishingDate = p.PublishingDate,
                Commission     = p.Commission,
                Images         = p.PropertyImage.Where(i => !i.Deleted && !i.Is360View).Select(i => new PropertyWebAppImageDto
                {
                    Id        = i.Id,
                    Order     = i.Priority,
                    ImagePath = i.ImagePath,
                    TumbPath  = i.TumbPath,
                }),
                AdditionalDetails = p.PropertyAdditionalDetail.Select(a => new PropertyAdditionalDetailDto
                {
                    Id    = a.Id,
                    Title = a.Title,
                    Value = a.Value
                }),
                Attachments = p.PropertyAttachment.Select(a => new PropertyAttachmentDto
                {
                    Id            = a.Id,
                    FileCaption   = a.FileCaption,
                    FileExtension = a.FileExtension,
                    FileSize      = a.FileSize,
                    UploadDate    = a.UploadDate
                }),
                FeatureIds = p.PropertyInvolveFeature.Select(f => f.PropertyFeatureId),
                FloorPlans = p.PropertyFloorPlan.Where(f => !f.Deleted).Select(f => new PropertyFloorPlanDto
                {
                    Id              = f.Id,
                    Bathrooms       = f.Bathrooms,
                    Bedrooms        = f.Bedrooms,
                    UploadDate      = f.UploadDate,
                    FloorName       = f.FloorName,
                    FloorPrice      = f.FloorPrice,
                    FloorSize       = f.FloorSize,
                    ImageCaption    = f.ImageCaption,
                    PropertyId      = f.PropertyId,
                    ImageExtension  = f.ImageExtension,
                    ImageSize       = f.ImageSize,
                    PlanDescription = f.PlanDescription,
                    PricePostfix    = f.PricePostfix,
                    SizePostfix     = f.SizePostfix,
                    ImagePath       = f.ImagePath,
                    TumbPath        = f.TumbPath,
                })
            }).FirstOrDefaultAsync(cancellationToken);

            if (propertyPage is null)
            {
                return(NotFound());
            }

            //propertyPage.ImagesId = propertyPage.ImagesId.OrderBy(a => a.Order).ToList();
            //propertyPage.ImagesUrl = new List<string>();
            //foreach (var i in propertyPage.ImagesId)
            //propertyPage.ImagesUrl.Add(i.ImagePath);
            //propertyPage.ImagesUrl.Add(
            //    _pathProvider.GetImageApiPath<PropertyImage>(
            //        nameof(PropertyImage.ImageContentFull), i.Id.ToString()));
            //propertyPage.FloorPlans = propertyPage.FloorPlans.ToList();
            //foreach (var i in propertyPage.FloorPlans)
            //    if (i.ImageSize > 0)
            //        i.ImageContentFullUrl = _pathProvider.GetImageApiPath<PropertyImage>(
            //                nameof(PropertyFloorPlan.ImageContentFull), i.Id.ToString());

            return(propertyPage);
        }
        AdvancedSearch(
            [FromQuery(Name = "page_number")] string pageNumber,
            [FromQuery(Name = "page_size")] string pageSize,
            [FromQuery(Name = "search")] string search,
            [FromQuery(Name = "type")] List <string> propertyTypes,
            [FromQuery(Name = "status")] List <string> propertyStatuses,
            [FromQuery(Name = "label")] List <string> propertyLabels,
            [FromQuery(Name = "feature")] List <string> propertyFeatures,
            [FromQuery(Name = "price_from")] string priceFrom,
            [FromQuery(Name = "price_to")] string priceTo,
            [FromQuery(Name = "size_from")] string sizeFrom,
            [FromQuery(Name = "size_to")] string sizeTo,
            [FromQuery(Name = "area_from")] string areaFrom,
            [FromQuery(Name = "area_to")] string areaTo,
            [FromQuery(Name = "rooms_from")] string roomsFrom,
            [FromQuery(Name = "rooms_to")] string roomsTo,
            [FromQuery(Name = "bed_rooms_from")] string bedRoomsFrom,
            [FromQuery(Name = "bed_rooms_to")] string bedRoomsTo,
            [FromQuery(Name = "bath_rooms_from")] string bathRoomsFrom,
            [FromQuery(Name = "bath_rooms_to")] string bathRoomsTo,
            [FromQuery(Name = "garages_from")] string garagesFrom,
            [FromQuery(Name = "garages_to")] string garagesTo,
            [FromQuery(Name = "garages_size_from")] string garagesSizeFrom,
            [FromQuery(Name = "garages_size_to")] string garagesSizeTo,
            [FromQuery(Name = "year_build_from")] string yearBuildFrom,
            [FromQuery(Name = "year_build_to")] string yearBuildTo,
            [FromQuery(Name = "floors_from")] string floorsFrom,
            [FromQuery(Name = "floors_to")] string floorsTo,
            [FromQuery(Name = "has_image")] string hasImage,
            [FromQuery(Name = "country")] string country,
            [FromQuery(Name = "region")] string region,
            [FromQuery(Name = "city")] string city,
            [FromQuery(Name = "lat")] string latitude,
            [FromQuery(Name = "long")] string longitude,
            CancellationToken cancellationToken)
        {
            var searchDto = CreateSearchDto(pageNumber,
                                            pageSize, search,
                                            propertyTypes, propertyStatuses,
                                            propertyLabels, propertyFeatures, priceFrom,
                                            priceTo, sizeFrom,
                                            sizeTo, areaFrom,
                                            areaTo, roomsFrom,
                                            roomsTo, bedRoomsFrom,
                                            bedRoomsTo, bathRoomsFrom,
                                            bathRoomsTo, garagesFrom,
                                            garagesTo, garagesSizeFrom,
                                            garagesSizeTo, yearBuildFrom,
                                            yearBuildTo, hasImage,
                                            country, region, city,
                                            floorsFrom, floorsTo,
                                            latitude, longitude);

            var propertyPage = await new PageResultDto <PropertyWebAppListDto>(
                CreateSearchPredicate(searchDto, ModelService.AsQueryable(p => p.IsPublished)
                                      .Include(p => p.PropertyPrice)
                                      .Include(p => p.PropertyDetail)
                                      .Include(p => p.PropertyLocation)
                                      .Include(p => p.PropertyImage))
                .Select(p => new PropertyWebAppListDto
            {
                Id               = p.Id,
                PropertyType     = p.PropertyType,
                PropertyTypeId   = p.PropertyTypeId,
                PropertyLabel    = p.PropertyLabel,
                PropertyLabelId  = p.PropertyLabelId,
                PropertyStatus   = p.PropertyStatus,
                PropertyStatusId = p.PropertyStatusId,
                Title            = p.Title,
                ZipCode          = p.Title,
                Price            = p.PropertyPrice,
                PriceSymbol      = p.PropertyPrice.Currency.Symbol,
                VideoUrl         = p.VideoUrl,
                Description      = p.Description,
                PropertyLocation = p.PropertyLocation,
                PropertyDetail   = p.PropertyDetail,
                PropertyUniqId   = p.PropertyUniqId,
                Commission       = p.Commission,
                Images           = p.PropertyImage.Where(i => !i.Deleted && !i.Is360View)
                                   .Select(i => new PropertyWebAppImageDto
                {
                    Id        = i.Id,
                    Order     = i.Priority,
                    ImagePath = i.ImagePath,
                    TumbPath  = i.TumbPath,
                }).ToList(),
                PublishingDate = p.PublishingDate,
            }), searchDto)
                               .GetPage(cancellationToken);

            //foreach (var dto in propertyPage.Items)
            //{
            //    dto.ImagesId = dto.ImagesId.OrderBy(a => a.Order).ToList();
            //    dto.ImagesUrl = new List<string>();
            //    foreach (var i in dto.ImagesId)
            //        dto.ImagesUrl.Add(
            //            _pathProvider.GetImageApiPath<PropertyImage>(
            //                nameof(PropertyImage.ImageContentTumblr), i.Id.ToString()));
            //}

            return(propertyPage);
        }