public async Task <ActionResult <PagedResults <BuildingResponse> > > GetBuidingNeedSurveyByAccountId([FromQuery] PagingRequestGetSurvey request)
        {
            Guid accountId = new Guid(User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
            var  rs        = await _buildingService.GetBuidingNeedSurveyByAccountId(accountId, request);

            return(Ok(rs));
        }
        public async Task <ActionResult <PagedResults <StoreResponse> > > GetStoreBySystemZoneId([FromQuery] PagingRequestGetSurvey model, int id)
        {
            Guid curentAccountId = new Guid(User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
            var  rs = await _systemZoneService.GeStoreBySystemzoneId(model, id, curentAccountId);

            return(Ok(rs));
        }
示例#3
0
        public async Task <PagedResults <StoreResponse> > GeStoreBySystemzoneId(PagingRequestGetSurvey model, int Id, Guid curentAccountId)
        {
            List <StoreResponse> list = null;

            try
            {
                bool isEdit         = false;
                var  systemzoneGeom = await _unitOfWork.Repository <SystemZone>().GetAll().Where(x => x.Id == Id).Select(x => new { x.Geom, x.Id }).AsNoTracking().SingleOrDefaultAsync();

                var systemzones = await _unitOfWork.Repository <SystemZone>().GetAll().Where(x => x.AccountId == curentAccountId).AsNoTracking().ToListAsync();

                isEdit = systemzones.Any(x => x.Id == systemzoneGeom.Id);
                List <StoreResponse> stores       = new List <StoreResponse>();
                List <StoreResponse> searchResult = new List <StoreResponse>();
                if (model.Status == Status.All)
                {
                    searchResult = await _unitOfWork.Repository <Store>()
                                   .GetAll()
                                   .Where(x => x.Name.ToLower()
                                          .Contains(model.KeySearch.ToLower()) &&
                                          systemzoneGeom.Geom.Intersects(x.Geom) && (x.Status != (int?)Status.Deleted && x.Status != (int?)Status.Reject && x.Status != (int?)Status.WaitingUpdate))
                                   .Select(x => new StoreResponse
                    {
                        IsEditable     = isEdit && (x.Status == (int?)Status.Surveyed || x.Status == (int?)Status.NeedSurvey),
                        Id             = x.Id,
                        Address        = x.Address,
                        FloorAreaId    = x.FloorAreaId,
                        FloorAreaName  = x.FloorArea != null ? x.FloorArea.Name : null,
                        Name           = x.Name,
                        BrandId        = x.BrandId,
                        BrandName      = x.Brand != null ? x.Brand.Name : null,
                        CreateDate     = x.CreateDate,
                        Geom           = x.Geom,
                        ImageUrl       = x.ImageUrl,
                        Status         = x.Status,
                        Type           = x.Brand.Segment.Name,
                        AbilityToServe = x.AbilityToServe,
                        SystemZoneId   = Id,
                        TimeSlot       = x.TimeSlot
                    })
                                   .ToListAsync();
                }
                else
                {
                    searchResult = await _unitOfWork.Repository <Store>()
                                   .GetAll()
                                   .Where(x => x.Name.ToLower()
                                          .Contains(model.KeySearch.ToLower()) &&
                                          systemzoneGeom.Geom.Intersects(x.Geom) && x.Status == (int)model.Status && (x.Status != (int?)Status.Deleted && x.Status != (int?)Status.Reject && x.Status != (int?)Status.WaitingUpdate))
                                   .Select(x => new StoreResponse
                    {
                        IsEditable     = isEdit && (x.Status == (int?)Status.Surveyed || x.Status == (int?)Status.NeedSurvey),
                        Id             = x.Id,
                        Address        = x.Address,
                        FloorAreaId    = x.FloorAreaId,
                        FloorAreaName  = x.FloorArea != null ? x.FloorArea.Name : null,
                        Name           = x.Name,
                        BrandId        = x.BrandId,
                        BrandName      = x.Brand != null ? x.Brand.Name : null,
                        CreateDate     = x.CreateDate,
                        Geom           = x.Geom,
                        ImageUrl       = x.ImageUrl,
                        Status         = x.Status,
                        Type           = x.Brand.Segment.Name,
                        AbilityToServe = x.AbilityToServe,
                        SystemZoneId   = Id,
                        TimeSlot       = x.TimeSlot
                    })
                                   .ToListAsync();
                }

                if (searchResult.Any())
                {
                    stores.AddRange(searchResult);
                }

                list = PageHelper <StoreResponse> .Sorting(model.SortType, stores.AsEnumerable(), model.ColName);

                var result = PageHelper <StoreResponse> .Paging(list, model.Page, model.PageSize);

                return(result);
            }
            catch (Exception e)
            {
                throw new CrudException(HttpStatusCode.BadRequest, "Get Store Error!!!", e.InnerException?.Message);
            }
        }
示例#4
0
        public async Task <PagedResults <StoreResponse> > GetStoreNeedSurveyByAccountId(Guid accountId, PagingRequestGetSurvey model)
        {
            List <StoreResponse> list = null;

            try
            {
                var systemZone = await _unitOfWork.Repository <SystemZone>().GetAll().Where(x => x.AccountId == accountId).ToListAsync();

                List <StoreResponse> stores = new List <StoreResponse>();
                foreach (var item in systemZone)
                {
                    var searchResult = await _unitOfWork.Repository <Store>()
                                       .GetAll()
                                       .Where(x => x.Name.ToLower()
                                              .Contains(model.KeySearch.ToLower()) &&
                                              item.Geom.Intersects(x.Geom) && x.Status == (int)model.Status && x.Status != (int?)Status.Deleted)
                                       .Select(x => new StoreResponse
                    {
                        Id             = x.Id,
                        Address        = x.Address,
                        FloorAreaId    = x.FloorAreaId,
                        FloorAreaName  = x.FloorArea != null ? x.FloorArea.Name : null,
                        Name           = x.Name,
                        BrandId        = x.BrandId,
                        BrandName      = x.Brand != null ? x.Brand.Name : null,
                        CreateDate     = x.CreateDate,
                        Geom           = x.Geom,
                        ImageUrl       = x.ImageUrl,
                        Status         = x.Status,
                        Type           = x.Brand.Segment.Name,
                        AbilityToServe = x.AbilityToServe,
                        SystemZoneId   = item.Id,
                        TimeSlot       = x.TimeSlot
                    })
                                       .ToListAsync();

                    if (searchResult.Count != 0)
                    {
                        stores.AddRange(searchResult);
                    }
                }
                list = PageHelper <StoreResponse> .Sorting(model.SortType, stores.AsEnumerable(), model.ColName);

                var result = PageHelper <StoreResponse> .Paging(list, model.Page, model.PageSize);

                return(result);
            }
            catch (Exception e)
            {
                throw new CrudException(HttpStatusCode.BadRequest, "Get Store Error!!!", e.InnerException?.Message);
            }
        }
示例#5
0
        public async Task <PagedResults <BuildingResponse> > GetBuidingBySystemzoneId(PagingRequestGetSurvey model, int Id, Guid curentAccountId)
        {
            List <BuildingResponse> list = null;

            try
            {
                List <BuildingResponse> buildings    = new List <BuildingResponse>();
                List <BuildingResponse> searchResult = new List <BuildingResponse>();
                bool isEdit         = false;
                var  systemzoneGeom = await _unitOfWork.Repository <SystemZone>().GetAll().Where(x => x.Id == Id).Select(x => new { x.Geom, x.Id }).AsNoTracking().SingleOrDefaultAsync();

                var systemzones = await _unitOfWork.Repository <SystemZone>().GetAll().Where(x => x.AccountId == curentAccountId).AsNoTracking().ToListAsync();

                isEdit = systemzones.Any(x => x.Id == systemzoneGeom.Id);
                if (model.Status == Status.All)
                {
                    searchResult = await _unitOfWork.Repository <Building>()
                                   .GetAll()
                                   .Where(x => x.Name.ToLower()
                                          .Contains(model.KeySearch.ToLower()) &&
                                          systemzoneGeom.Geom.Intersects(x.Geom) && (x.Status != (int?)Status.Deleted && x.Status != (int?)Status.Reject && x.Status != (int?)Status.WaitingUpdate))
                                   .Select(x => new BuildingResponse
                    {
                        Id            = x.Id,
                        IsEditable    = isEdit && (x.Status == (int?)Status.Surveyed || x.Status == (int?)Status.NeedSurvey),
                        Name          = x.Name,
                        Geom          = x.Geom,
                        NumberOfFloor = x.NumberOfFloor,
                        Active        = x.Active,
                        CampusId      = x.CampusId,
                        CreateDate    = x.CreateDate,
                        ImageUrl      = x.ImageUrl,
                        Type          = x.Type.Name,
                        Address       = x.Address,
                        Status        = x.Status,
                        SystemZoneId  = Id,
                        Floors        = new List <FloorResopnse>(x.Floors.Select(f => new FloorResopnse
                        {
                            Id          = f.Id,
                            Name        = f.Name,
                            BuildingId  = f.BuildingId,
                            FloorNumber = f.FloorNumber,
                            FloorAreas  = new List <FloorAreaResopnse>(f.FloorAreas.Select(a => new FloorAreaResopnse
                            {
                                Id      = a.Id,
                                FloorId = a.FloorId,
                                Name    = a.Name,
                                Stores  = new List <StoreResponse>(a.Stores.Select(s => new StoreResponse
                                {
                                    Name          = s.Name,
                                    Address       = s.Address,
                                    FloorAreaName = s.FloorArea != null ? s.FloorArea.Name : null,
                                    BrandName     = s.Brand != null ? s.Brand.Name : null,
                                    CreateDate    = s.CreateDate,
                                    Geom          = s.Geom,
                                    Id            = s.Id,
                                    FloorAreaId   = s.FloorAreaId,
                                    BrandId       = s.BrandId,
                                    ImageUrl      = s.ImageUrl,
                                    Type          = s.Brand.Segment.Name,
                                    Status        = s.Status,
                                    ReferenceId   = s.ReferenceId
                                }))
                            }))
                        }))
                    })
                                   .ToListAsync();
                }
                else
                {
                    searchResult = await _unitOfWork.Repository <Building>()
                                   .GetAll()
                                   .Where(x => x.Name.ToLower()
                                          .Contains(model.KeySearch.ToLower()) &&
                                          systemzoneGeom.Geom.Intersects(x.Geom) && x.Status == (int)model.Status && (x.Status != (int?)Status.Deleted && x.Status != (int?)Status.Reject && x.Status != (int?)Status.WaitingUpdate))
                                   .Select(x => new BuildingResponse
                    {
                        IsEditable    = isEdit && (x.Status == (int?)Status.Surveyed || x.Status == (int?)Status.NeedSurvey),
                        Id            = x.Id,
                        Name          = x.Name,
                        Geom          = x.Geom,
                        NumberOfFloor = x.NumberOfFloor,
                        Active        = x.Active,
                        CampusId      = x.CampusId,
                        CreateDate    = x.CreateDate,
                        ImageUrl      = x.ImageUrl,
                        Type          = x.Type.Name,
                        Address       = x.Address,
                        Status        = x.Status,
                        SystemZoneId  = Id,

                        Floors = new List <FloorResopnse>(x.Floors.Select(f => new FloorResopnse
                        {
                            Id          = f.Id,
                            Name        = f.Name,
                            BuildingId  = f.BuildingId,
                            FloorNumber = f.FloorNumber,
                            FloorAreas  = new List <FloorAreaResopnse>(f.FloorAreas.Select(a => new FloorAreaResopnse
                            {
                                Id      = a.Id,
                                FloorId = a.FloorId,
                                Name    = a.Name,
                                Stores  = new List <StoreResponse>(a.Stores.Select(s => new StoreResponse
                                {
                                    Name          = s.Name,
                                    Address       = s.Address,
                                    FloorAreaName = s.FloorArea != null ? s.FloorArea.Name : null,
                                    BrandName     = s.Brand != null ? s.Brand.Name : null,
                                    CreateDate    = s.CreateDate,
                                    Geom          = s.Geom,
                                    Id            = s.Id,
                                    FloorAreaId   = s.FloorAreaId,
                                    BrandId       = s.BrandId,
                                    ImageUrl      = s.ImageUrl,
                                    Type          = s.Brand.Segment.Name,
                                    Status        = s.Status,
                                    ReferenceId   = s.ReferenceId
                                }))
                            }))
                        }))
                    })
                                   .ToListAsync();
                }
                if (searchResult.Any())
                {
                    buildings.AddRange(searchResult);
                }

                list = PageHelper <BuildingResponse> .Sorting(model.SortType, buildings.AsEnumerable(), model.ColName);

                var result = PageHelper <BuildingResponse> .Paging(list, model.Page, model.PageSize);

                return(result);
            }
            catch (Exception e)
            {
                throw new CrudException(HttpStatusCode.BadRequest, "Get Building Error!!!", e.InnerException?.Message);
            }
        }