예제 #1
0
        public async Task Recommender()
        {
            RecommenderList.Clear();
            List <Model.Models.Artikli> lista = new List <Model.Models.Artikli>();

            lista = await _recommenderService.GetSlicneArtikle <List <Model.Models.Artikli> >(Artikal.ArtikalId);

            List <Model.Models.Ocjene> listaocjena = new List <Model.Models.Ocjene>();

            listaocjena = await _ocjeneService.Get <List <Model.Models.Ocjene> >(null);



            foreach (var item in lista)
            {
                int     ukupno = 0;
                decimal iznos  = 0;

                foreach (var item2 in listaocjena)
                {
                    if (item2.ArtikalId == item.ArtikalId)
                    {
                        iznos += item2.Ocjena;
                        ukupno++;
                    }
                }

                item.ProsjecnaOcjena = iznos / ukupno;


                RecommenderList.Add(item);
            }
        }
예제 #2
0
        public async Task Recommender()
        {
            RecommenderList.Clear();
            List <PutovanjaVM> lista = new List <PutovanjaVM>();

            lista = await _recommenderService.GetSlicnaPutovanja <List <PutovanjaVM> >(Putovanje.PutovanjeID);

            List <PretragaVM> listaPrOcjena = new List <PretragaVM>();

            listaPrOcjena = await _pretragaOcjeneService.Get <List <PretragaVM> >(null);



            foreach (var item in lista)
            {
                int     ukupno = 0;
                decimal iznos  = 0;

                foreach (var item2 in listaPrOcjena)
                {
                    if (item2.RelacijaId == item.RelacijaID)
                    {
                        iznos += Convert.ToDecimal(item2.Ocjena);
                        ukupno++;
                    }
                }

                item.ProsjecnaOcjena = iznos / ukupno;

                RecommenderList.Add(item);
            }
        }
        public async Task Recommend()
        {
            IsBusy = false;
            RecommenderList.Clear();
            List <Model.Products> list = new List <Model.Products>();

            list = await _recommenderService.GetAlikeProducts <List <Model.Products> >(Product.Id);

            List <Model.Reviews.Reviews> reviewList = new List <Model.Reviews.Reviews>();

            reviewList = await _reviewsService.Get <List <Model.Reviews.Reviews> >(null);

            if (list.Count == 0)
            {
                IsBusy = true;
            }

            foreach (var item in list)
            {
                //    int total = 0;
                //    decimal sum = 0;

                //    foreach (var tmp in reviewList)
                //    {
                //        if (tmp.ProductId == item.Id)
                //        {
                //            total += tmp.Review;
                //            sum++;
                //        }
                //    }

                //    Average.Add(sum / total);

                RecommenderList.Add(item);
            }
        }