public async Task <IHttpActionResult> GetCommonCodes([FromUri] PetterRequestType petterRequestType)
        {
            PetterResultType <CommonCode> petterResultType = new PetterResultType <CommonCode>();
            List <CommonCode>             list             = new List <CommonCode>();

            var commonCode = db.CommonCodes.AsEnumerable();

            // 검색 조건
            if (!String.IsNullOrEmpty(petterRequestType.Search))
            {
                commonCode = commonCode.Where(p => p.ParentCodeID != null && p.ParentCodeID.Contains(petterRequestType.Search));
            }

            #region 정렬 방식
            switch (petterRequestType.SortBy)
            {
            // 기본
            default:
            {
                list = commonCode
                       .OrderBy(p => p.OrderNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }
            }
            #endregion 정렬방식

            petterResultType.IsSuccessful = true;
            petterResultType.AffectedRow  = list.Count();
            petterResultType.JsonDataSet  = list.ToList();
            return(Ok(petterResultType));
        }
        public async Task <IHttpActionResult> GetStoreReviews([FromUri] PetterRequestType petterRequestType)
        {
            PetterResultType <StoreReview> petterResultType = new PetterResultType <StoreReview>();
            List <StoreReview>             list             = new List <StoreReview>();
            bool isSearch = false;

            // 검색 조건
            if (!String.IsNullOrWhiteSpace(petterRequestType.Search))
            {
                isSearch = true;
            }

            #region 정렬 방식
            switch (petterRequestType.SortBy)
            {
            // 평점
            case "grade":
            {
                list = await db.StoreReviews
                       .Where(p => petterRequestType.StateFlag == "A"? 1 == 1 : p.StateFlag == petterRequestType.StateFlag)
                       //.Where(p => isSearch ? p.Content.Contains(petterRequestType.Search) : 1 == 1)
                       //.OrderByDescending(p => p.grade)
                       .OrderByDescending(p => p.StoreReviewNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToListAsync();

                break;
            }

            // 기본
            default:
            {
                list = await db.StoreReviews
                       .Where(p => petterRequestType.StateFlag == "A"? 1 == 1 : p.StateFlag == petterRequestType.StateFlag)
                       //.Where(p => isSearch ? p.Content.Contains(petterRequestType.Search) : 1 == 1)
                       .OrderByDescending(p => p.StoreReviewNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToListAsync();

                break;
            }
            }
            #endregion 정렬방식

            if (list == null)
            {
                return(NotFound());
            }

            petterResultType.IsSuccessful = true;
            petterResultType.JsonDataSet  = list.ToList();

            return(Ok(petterResultType));
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> GetMembers([FromUri] PetterRequestType petterRequestType)
        {
            PetterResultType <Member> petterResultType = new PetterResultType <Member>();
            List <Member>             list             = new List <Member>();
            bool isSearch = false;

            // 검색 조건
            if (!String.IsNullOrWhiteSpace(petterRequestType.Search))
            {
                isSearch = true;
            }

            #region 정렬 방식
            switch (petterRequestType.SortBy)
            {
            // 정렬 조건
            case "조건":
            {
                list = await db.Members
                       .Where(p => p.StateFlag == "D")
                       .Where(p => isSearch ? p.NickName.Contains(petterRequestType.Search) : 1 == 1)
                       .OrderByDescending(p => p.MemberNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToListAsync();

                break;
            }

            // 기본
            default:
            {
                list = await db.Members
                       .Where(p => petterRequestType.StateFlag == "A"? 1 == 1 : p.StateFlag == petterRequestType.StateFlag)
                       .Where(p => isSearch ? p.NickName.Contains(petterRequestType.Search) : 1 == 1)
                       .OrderByDescending(p => p.MemberNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToListAsync();

                break;
            }
            }
            #endregion 정렬방식

            if (list == null)
            {
                return(NotFound());
            }

            petterResultType.IsSuccessful = true;
            petterResultType.AffectedRow  = list.Count();
            petterResultType.JsonDataSet  = list.ToList();
            return(Ok(petterResultType));
        }
Ejemplo n.º 4
0
        // GET: api/Pensions
        public IEnumerable <Pension> GetPensions([FromUri] PetterRequestType petterRequestType)
        {
            List <Pension> list            = new List <Pension>();
            DbGeography    currentLocation = DbGeography.FromText(string.Format("POINT({0} {1})", petterRequestType.Longitude, petterRequestType.Latitude));
            int            distance        = petterRequestType.Distance;

            var Pension = db.Pensions.AsEnumerable();

            // 검색 조건
            if (!String.IsNullOrWhiteSpace(petterRequestType.Search))
            {
                Pension = Pension.Where(p => p.PensionName != null && p.PensionName.Contains(petterRequestType.Search));
            }

            #region 정렬 방식
            switch (petterRequestType.SortBy)
            {
            // 거리
            case "distance":
            {
                list = Pension
                       .Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       .OrderBy(p => p.Coordinate.Distance(currentLocation))
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }

            // 리뷰수
            case "reviewcount":
            {
                list = Pension
                       .Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       //.OrderByDescending(p => p.ReviewCount)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }

            // 점수
            case "grade":
            {
                list = Pension
                       .Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       //.OrderByDescending(p => p.Grade)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }

            // 즐겨찾기
            case "bookmark":
            {
                list = Pension
                       .Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       //.OrderByDescending(p => p.Bookmark)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }

            // 기본
            default:
            {
                list = Pension
                       .Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       .OrderByDescending(p => p.CompanyNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }
            }
            #endregion 정렬방식

            return(list);
        }
        public async Task <IHttpActionResult> GetEventBoards([FromUri] PetterRequestType petterRequestType)
        {
            PetterResultType <EventBoard> petterResultType = new PetterResultType <EventBoard>();
            List <EventBoard>             list             = new List <EventBoard>();
            bool isSearch = false;

            //var EventBoards = await db.EventBoards.ToListAsync();

            // 검색 조건
            //if (!String.IsNullOrWhiteSpace(petterRequestType.Search))
            //{
            //    //EventBoards = EventBoards.Where(p => p.Title.Contains(petterRequestType.Search));
            //}

            //// 상태 조건
            //if (!String.IsNullOrWhiteSpace(petterRequestType.Search) && petterRequestType.StateFlag != "A")
            //{
            //    //EventBoards = EventBoards.Where(p => p.StateFlag == petterRequestType.StateFlag);
            //}

            // 검색 조건
            if (!String.IsNullOrWhiteSpace(petterRequestType.Search))
            {
                isSearch = true;
            }

            #region 정렬 방식
            switch (petterRequestType.SortBy)
            {
            // 리뷰수
            case "reviewcount":
            {
                list = await db.EventBoards
                       .Where(p => petterRequestType.StateFlag == "A"? 1 == 1 : p.StateFlag == petterRequestType.StateFlag)
                       .Where(p => isSearch ? p.Title.Contains(petterRequestType.Search) : 1 == 1)
                       //.OrderByDescending(p => p.ReviewCount)
                       .OrderByDescending(p => p.EventBoardNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToListAsync();

                break;
            }

            // 기본
            default:
            {
                list = await db.EventBoards
                       .Where(p => petterRequestType.StateFlag == "A"? 1 == 1 : p.StateFlag == petterRequestType.StateFlag)
                       .Where(p => isSearch ? p.Title.Contains(petterRequestType.Search) : 1 == 1)
                       .OrderByDescending(p => p.EventBoardNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToListAsync();

                break;
            }
            }
            #endregion 정렬방식

            if (list == null)
            {
                return(NotFound());
            }

            petterResultType.IsSuccessful = true;
            petterResultType.JsonDataSet  = list.ToList();
            return(Ok(petterResultType));

            //return list;
        }
Ejemplo n.º 6
0
        public async Task <IHttpActionResult> GetStore([FromUri] PetterRequestType petterRequestType)
        {
            PetterResultType <Store> petterResultType = new PetterResultType <Store>();
            List <Store>             list             = new List <Store>();
            // 서울 (경도: 126.9784, 위도: 37.5667)
            DbGeography currentLocation = DbGeography.FromText(string.Format("POINT({0} {1})", petterRequestType.Longitude, petterRequestType.Latitude));
            int         distance        = petterRequestType.Distance;

            var store = db.Stores.AsEnumerable();

            // 검색 조건
            if (!String.IsNullOrEmpty(petterRequestType.Search))
            {
                store = store.Where(p => p.StoreName != null && p.StoreName.Contains(petterRequestType.Search));
            }

            #region 정렬 방식
            switch (petterRequestType.SortBy)
            {
            // 거리
            case "distance":
            {
                list = store
                       .Where(p => petterRequestType.CodeID == petterRequestType.CodeID)
                       //.Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       .OrderByDescending(p => p.StoreNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }

            // 리뷰수
            case "reviewcount":
            {
                list = store
                       .Where(p => petterRequestType.CodeID == petterRequestType.CodeID)
                       //.Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       //.OrderByDescending(p => p.ReviewCount)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }

            // 점수
            case "grade":
            {
                list = store
                       .Where(p => petterRequestType.CodeID == petterRequestType.CodeID)
                       //.Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       //.OrderByDescending(p => p.Grade)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }

            // 즐겨찾기
            case "bookmark":
            {
                list = store
                       .Where(p => petterRequestType.CodeID == petterRequestType.CodeID)
                       //.Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       //.OrderByDescending(p => p.Bookmark)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }

            // 기본
            default:
            {
                list = store
                       .Where(p => petterRequestType.CodeID == petterRequestType.CodeID)
                       //.Where(p => p.Coordinate.Distance(currentLocation) <= distance)
                       .OrderByDescending(p => p.CompanyNo)
                       .Skip((petterRequestType.CurrentPage - 1) * petterRequestType.ItemsPerPage)
                       .Take(petterRequestType.ItemsPerPage).ToList();
                break;
            }
            }
            #endregion 정렬방식

            petterResultType.IsSuccessful = true;
            petterResultType.AffectedRow  = list.Count();
            petterResultType.JsonDataSet  = list.ToList();
            return(Ok(petterResultType));
        }
Ejemplo n.º 7
0
        public async Task <IHttpActionResult> GetBoard([FromUri] PetterRequestType petterRequestType)
        {
            PetterResultType <BoardDTO> petterResultType = new PetterResultType <BoardDTO>();
            List <BoardDTO>             list             = new List <BoardDTO>();
            bool isSearch = false;

            // 검색 조건
            if (!String.IsNullOrWhiteSpace(petterRequestType.Search))
            {
                isSearch = true;
            }

            if (isSearch)
            {
            }

            #region 정렬 방식
            switch (petterRequestType.SortBy)
            {
            // 댓글수
            case "replycount":
            {
                list = await(from board in db.Boards
                             join member in db.Members on board.MemberID equals member.MemberID
                             join store in db.Stores on board.StoreNo equals store.StoreNo
                             where board.CodeID == petterRequestType.CodeID
                             orderby board.BoardNo descending
                             select new BoardDTO
                    {
                        BoardNo      = board.BoardNo,
                        StoreNo      = board.StoreNo,
                        CodeID       = board.CodeID,
                        Title        = board.Title,
                        Content      = board.Content,
                        NickName     = member.NickName,
                        StoreName    = store.StoreName,
                        StateFlag    = board.StateFlag,
                        DateCreated  = board.DateCreated,
                        DateModified = board.DateModified,
                        DateDeleted  = board.DateDeleted,
                        FileName     = board.FileName,
                        FilePath     = board.FilePath,
                        BoardStats   = board.BoardStats.ToList(),
                        BoardFiles   = board.BoardFiles.ToList(),
                        BoardLikes   = board.BoardLikes.ToList()
                                       //isCount = p.BoardLikes.Where(p.MemberNO == memberNo),
                                       //BoardReplies = board.BoardReplies.ToList()
                    }).ToListAsync();
                break;
            }

            // 기본
            default:
            {
                list = await(from board in db.Boards
                             join member in db.Members on board.MemberID equals member.MemberID
                             join store in db.Stores on board.StoreNo equals store.StoreNo
                             where board.CodeID == petterRequestType.CodeID
                             orderby board.BoardNo descending
                             select new BoardDTO
                    {
                        BoardNo      = board.BoardNo,
                        StoreNo      = board.StoreNo,
                        CodeID       = board.CodeID,
                        Title        = board.Title,
                        Content      = board.Content,
                        NickName     = member.NickName,
                        StoreName    = store.StoreName,
                        StateFlag    = board.StateFlag,
                        DateCreated  = board.DateCreated,
                        DateModified = board.DateModified,
                        DateDeleted  = board.DateDeleted,
                        FileName     = board.FileName,
                        FilePath     = board.FilePath,
                        BoardStats   = board.BoardStats.ToList(),
                        BoardFiles   = board.BoardFiles.ToList(),
                        BoardLikes   = board.BoardLikes.ToList()
                                       //isCount = board.BoardLikes.Where(p.MemberNO == memberNo),
                                       //BoardReplies = board.BoardReplies.ToList()
                    }).ToListAsync();
                break;
            }
            }
            #endregion 정렬방식

            if (list == null)
            {
                return(NotFound());
            }

            petterResultType.IsSuccessful = true;
            petterResultType.AffectedRow  = list.Count();
            petterResultType.JsonDataSet  = list.ToList();
            return(Ok(petterResultType));
        }