Esempio n. 1
0
        public IActionResult Index()
        {
            //    //var getDoctors = this.userAccService.AddAsyncDoctor().GetAwaiter().GetResult();
            //    //bestdoctors.bg get 750 doctors info
            //    // var getDoctor = this.userAccService.AddDoctor(41, 50).GetAwaiter().GetResult();


            //    // idc some test get email m8 be
            //    // var tesst = new UserinformationViewModel();

            //    // for (int i = 1; i < 3; i++)
            //    // {
            //    //     var getnick = this.userInfoService.GetByUserId<UserinformationViewModel>(i);
            //    //     var nick = getnick.NickName.Replace("(", String.Empty);
            //    //     var nickN = nick.Replace(")", String.Empty);
            //    //     this.userInfoService.Email(nickN);
            //    // }

            //    // get users from pmgl rdy
            //   var from = 6611;
            //   var to = 6640;
            //
            //   for (int i = 0; i < 3; i++)
            //   {
            //       var information = this.userInfoService.AddAsync(from, to);
            //       from += 30;
            //       to += 30;
            //   }

            //    if (name != null)
            //    {
            //        search = name;
            //    }
            //    this.ViewBag.Search = search;
            //    this.ViewBag.Name = name;
            //    this.ViewBag.Region = region;
            //    this.ViewBag.Specialty = specialty;

            //    if (search != null && region != null && specialty != specialty)
            //    {
            //        var foundUserAndRegion = new UsersAccViewModel
            //        {
            //            Users = this.userAccService.SearchUserAndRegionAndSpecialty<UserAccViewModel>(search, region, specialty),
            //        };

            //        return this.View(foundUserAndRegion);

            //    }else if (search != null && region != null)
            //    {
            //        var foundUserAndRegion = new UsersAccViewModel
            //        {
            //            Users = this.userAccService.SearchUserAndRegion<UserAccViewModel>(search, region),
            //        };

            //        return this.View(foundUserAndRegion);
            //    }else if (search != null && specialty != specialty)
            //    {
            //        var foundUserAndRegion = new UsersAccViewModel
            //        {
            //            Users = this.userAccService.SearchUserAndSpecialty<UserAccViewModel>(search, specialty),
            //        };

            //        return this.View(foundUserAndRegion);
            //    }
            //    else if (specialty != specialty && region != null)
            //    {
            //        var foundUserAndRegion = new UsersAccViewModel
            //        {
            //            Users = this.userAccService.SearchSpecialtyAndRegion<UserAccViewModel>(specialty, region),
            //        };

            //        return this.View(foundUserAndRegion);
            //    }
            //    else if (!string.IsNullOrEmpty(search))
            //    {
            //        var foundUser = new UsersAccViewModel
            //        {
            //            Users = this.userAccService.Search<UserAccViewModel>(search, ItemPerPage, (page - 1) * ItemPerPage),
            //        };

            //        var doctorsCount = this.userAccService.SearchCount(search);
            //        foundUser.PagesCount = (int)Math.Ceiling((double)doctorsCount / ItemPerPage);
            //        foundUser.CurrentPage = page;
            //        return this.View(foundUser);
            //    }
            //    else if (!string.IsNullOrEmpty(region))
            //    {
            //        var foundRegion = new UsersAccViewModel
            //        {
            //            Users = this.userAccService.SearchRegion<UserAccViewModel>(region),
            //        };

            //        return this.View(foundRegion);
            //    }
            //    else if (!string.IsNullOrEmpty(specialty))
            //    {
            //        var foundRegion = new UsersAccViewModel
            //        {
            //            Users = this.userAccService.SearchSpecialty<UserAccViewModel>(specialty),
            //        };
            //        return this.View(foundRegion);
            //    }

            //    // var viewModel = new UsersAccViewModel();

            //    // viewModel.Users = this.userAccService.GetAll<UserAccViewModel>();
            //    var instanceOfoBject = new UsersAccViewModel();
            //    instanceOfoBject.PagesCount = 0;

            var mostVotedDocId   = this.userAccService.MostVotedDoc();
            var mostCommentDocId = this.userAccService.MostCommentDoc();

            var mostVotedDoctors = new UsersAccViewModel
            {
                Users = this.userAccService.GetMostVoted <UserAccViewModel>(mostVotedDocId),
                Doc   = this.userAccService.GetMostVoted <UserAccViewModel>(mostCommentDocId),
            };

            return(this.View(mostVotedDoctors));
        }
        public IActionResult doctorResult(string search, string region, string specialty, string name, string searchId, int page = 1)
        {
            if (search != null && region != null && specialty != "Specialty")
            {
            }
            else if (search != null && region != null)
            {
            }
            else if (search != null && specialty != "Specialty")
            {
            }
            else if (region != null && specialty != "Specialty")
            {
            }
            else if (name != null)
            {
                var inputParts = name.Split(' ');

                if (inputParts.Length == 3)
                {
                    var keyNumber = int.Parse(inputParts[0]);
                    var firstPart = inputParts[1];
                    var secPart   = inputParts[2];
                    if (keyNumber == 1)
                    {
                        search = firstPart;
                        region = secPart;
                    }
                    else if (keyNumber == 2)
                    {
                        search    = firstPart;
                        specialty = secPart;
                    }
                    else
                    {
                        region    = firstPart;
                        specialty = secPart;
                    }
                }
                else if (inputParts.Length == 4)
                {
                    var firstPart = inputParts[0];
                    var secPart   = inputParts[1];
                    var thyrdPart = inputParts[2];

                    search    = firstPart;
                    region    = secPart;
                    specialty = thyrdPart;
                }
            }

            if (search != null)
            {
                name = null;
            }
            else if (searchId == "search")
            {
                search = name;
            }

            if (region != null)
            {
                name = null;
            }
            else if (searchId == "region")
            {
                region = name;
            }

            if (specialty != "Specialty" && specialty != null)
            {
                name = null;
            }
            else if (searchId == "specialty")
            {
                specialty = name;
            }

            this.ViewBag.Search    = search;
            this.ViewBag.Name      = name;
            this.ViewBag.Region    = region;
            this.ViewBag.Specialty = specialty;

            if (search != null && region != null && specialty != "Specialty" && specialty != null)
            {
                var foundUserAndRegion = new UsersAccViewModel
                {
                    Users = this.userAccService.SearchUserAndRegionAndSpecialty <UserAccViewModel>(search, region, specialty, ItemPerPage, (page - 1) * ItemPerPage),
                };

                var doctorsCount = this.userAccService.SearchCount(search, region, specialty);
                foundUserAndRegion.PagesCount = (int)Math.Ceiling((double)doctorsCount / ItemPerPage);
                if (foundUserAndRegion.PagesCount == 0)
                {
                    foundUserAndRegion.PagesCount = 1;
                }

                foundUserAndRegion.CurrentPage = page;

                return(this.View(foundUserAndRegion));
            }
            else if (search != null && region != null)
            {
                var foundUserAndRegion = new UsersAccViewModel
                {
                    Users = this.userAccService.SearchUserAndRegion <UserAccViewModel>(search, region, ItemPerPage, (page - 1) * ItemPerPage),
                };

                var doctorsCount = this.userAccService.SearchCount(search, region, specialty);
                foundUserAndRegion.PagesCount = (int)Math.Ceiling((double)doctorsCount / ItemPerPage);
                if (foundUserAndRegion.PagesCount == 0)
                {
                    foundUserAndRegion.PagesCount = 1;
                }

                foundUserAndRegion.CurrentPage = page;

                return(this.View(foundUserAndRegion));
            }
            else if (search != null && specialty != "Specialty" && specialty != null)
            {
                var foundUserAndRegion = new UsersAccViewModel
                {
                    Users = this.userAccService.SearchUserAndSpecialty <UserAccViewModel>(search, specialty, ItemPerPage, (page - 1) * ItemPerPage),
                };

                var doctorsCount = this.userAccService.SearchCount(search, region, specialty);
                foundUserAndRegion.PagesCount = (int)Math.Ceiling((double)doctorsCount / ItemPerPage);
                if (foundUserAndRegion.PagesCount == 0)
                {
                    foundUserAndRegion.PagesCount = 1;
                }

                foundUserAndRegion.CurrentPage = page;

                return(this.View(foundUserAndRegion));
            }
            else if (specialty != "Specialty" && specialty != null && region != null)
            {
                var foundUserAndRegion = new UsersAccViewModel
                {
                    Users = this.userAccService.SearchSpecialtyAndRegion <UserAccViewModel>(specialty, region, ItemPerPage, (page - 1) * ItemPerPage),
                };

                var doctorsCount = this.userAccService.SearchCount(search, region, specialty);
                foundUserAndRegion.PagesCount = (int)Math.Ceiling((double)doctorsCount / ItemPerPage);
                if (foundUserAndRegion.PagesCount == 0)
                {
                    foundUserAndRegion.PagesCount = 1;
                }

                foundUserAndRegion.CurrentPage = page;

                return(this.View(foundUserAndRegion));
            }
            else if (!string.IsNullOrEmpty(search))
            {
                var foundUser = new UsersAccViewModel
                {
                    Users = this.userAccService.Search <UserAccViewModel>(search, ItemPerPage, (page - 1) * ItemPerPage),
                };

                var doctorsCount = this.userAccService.SearchCount(search, region, specialty);
                foundUser.PagesCount = (int)Math.Ceiling((double)doctorsCount / ItemPerPage);
                if (foundUser.PagesCount == 0)
                {
                    foundUser.PagesCount = 1;
                }

                foundUser.CurrentPage = page;
                return(this.View(foundUser));
            }
            else if (!string.IsNullOrEmpty(region))
            {
                var foundRegion = new UsersAccViewModel
                {
                    Users = this.userAccService.SearchRegion <UserAccViewModel>(region, ItemPerPage, (page - 1) * ItemPerPage),
                };

                var doctorsCount = this.userAccService.SearchCount(search, region, specialty);
                foundRegion.PagesCount = (int)Math.Ceiling((double)doctorsCount / ItemPerPage);
                if (foundRegion.PagesCount == 0)
                {
                    foundRegion.PagesCount = 1;
                }

                foundRegion.CurrentPage = page;

                return(this.View(foundRegion));
            }
            else if (specialty != "Specialty" && specialty != null)
            {
                var foundRegion = new UsersAccViewModel
                {
                    Users = this.userAccService.SearchSpecialty <UserAccViewModel>(specialty, ItemPerPage, (page - 1) * ItemPerPage),
                };

                var doctorsCount = this.userAccService.SearchCount(search, region, specialty);
                foundRegion.PagesCount = (int)Math.Ceiling((double)doctorsCount / ItemPerPage);
                if (foundRegion.PagesCount == 0)
                {
                    foundRegion.PagesCount = 1;
                }
                foundRegion.CurrentPage = page;

                return(this.View(foundRegion));
            }

            // var viewModel = new UsersAccViewModel();
            // viewModel.Users = this.userAccService.GetAll<UserAccViewModel>();
            var instanceOfoBject = new UsersAccViewModel();

            instanceOfoBject.PagesCount = 0;

            return(this.View(instanceOfoBject));
        }