public IActionResult PutARating(long id_Doctor, [FromBody] RatingViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }
            var doc = db.Doctor.FirstOrDefault(d => d.Id == id_Doctor);

            if (doc == null)
            {
                return(BadRequest());
            }
            doc.TotalSumRating = model.TotalSumRating;
            doc.NumRated       = model.NumRated;
            doc.Rating         = model.Rating;
            db.Update(doc);
            db.SaveChanges();
            Appreciated ap = (Appreciated)model;

            ap.Fk_Doctor = id_Doctor;
            db.Add(ap);
            db.SaveChanges();
            return(Ok(new
            {
                doctor = doc,
                appreciated = ap
            }));
        }
예제 #2
0
        //this logic is used to fetch the values present in the rating column in the table
        public RatingViewModel Ratings()
        {
            RatingViewModel model = new RatingViewModel();

            try
            {
                using (var db = new Orchard9Entities())
                {
                    model.Ratings = (from book in db.tblBooks
                                     where book.isactive == true
                                     orderby book.Rating ascending
                                     select book.Rating).Distinct().ToList();
                }

                if (model.Ratings.Count > 0)
                {
                    model.StatusMessage = "Success";
                }
                else
                {
                    model.StatusMessage = "No Categories found";
                }
            }

            catch (Exception ex)
            {
                model.StatusMessage = ex.Message;
            }
            return(model);
        }
        public RatingViewModel GetTemplateRating(int templateId)
        {
            var template = new Template();

            template = _templateRepository.GetById(templateId);

            var model = new RatingViewModel();

            model.QuestionsList = new List <Questions>();

            if (template != null)
            {
                var tempQuestions = _templateQuestionRepository.GetByTemplateId(templateId);

                int[] questionType = { 3, 4, 5 };

                model.QuestionsList = (from que in tempQuestions
                                       select new Questions
                {
                    QuestionId = que.TemplateQuesID,
                    QuestionTitle = que.Question,
                    QuestionType = Convert.ToInt32(que.AnswerType),
                    AnswersList = !questionType.Contains(Convert.ToInt32(que.AnswerType)) ? new List <AnswersOfQuestion>() : (from ans in que.AnswerDetails.Split(',')
                                                                                                                              select new AnswersOfQuestion
                    {
                        AnswerId = 1,
                        AnswerTitle = ans
                    }).ToList()
                }).ToList();
            }
            return(model);
        }
        public IActionResult ChangeRating(long id_Doctor, [FromBody] RatingViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }
            var doc = db.Doctor.FirstOrDefault(d => d.Id == id_Doctor);

            if (doc == null)
            {
                return(BadRequest());
            }
            doc.TotalSumRating = model.TotalSumRating;
            doc.NumRated       = model.NumRated;
            doc.Rating         = model.Rating;
            db.Update(doc);
            db.SaveChanges();
            Appreciated ap = db.Appreciated.FirstOrDefault(a => a.Id == model.Id_Appreciated);

            ap.Fk_Doctor  = id_Doctor;
            ap.Fk_User    = model.Id_User;
            ap.Assessment = model.Assessment;
            ap.dateTime   = DateTime.Now;
            db.Update(ap);
            db.SaveChanges();
            return(Ok(new
            {
                doctor = doc,
                appreciated = ap
            }));
        }
예제 #5
0
        public async Task <IHttpActionResult> SaveRating(RatingViewModel model)
        {
            try
            {
                //string userName = User.Identity.GetUserName();
                //ApplicationUser user = await GetApplicationUser(userName);


                model.UserId = GetUserId();

                var rating = _UnitOfWork.RatingRepository.All().FirstOrDefault(u => u.AgentId == model.AgentId && u.UserId == model.UserId);
                if (rating != null)
                {
                    rating.Degree = model.Degree;
                    _UnitOfWork.Commit();
                    return(Ok(rating));
                }
                else
                {
                    var rate   = Mapper.Map <RatingViewModel, Rating>(model);
                    var result = _UnitOfWork.RatingRepository.Create(rate);
                    _UnitOfWork.Commit();

                    return(Ok(result));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
예제 #6
0
        // GET: Rating
        public ActionResult Index(int page = 1, int pageSize = 10)
        {
            //ViewBag.GeneralParcelId = new SelectList(db.GeneralInfoParcels, "Id", "ParcelNo");

            List <RatingViewModel> RatingList = new List <RatingViewModel>();

            foreach (var general in db.GeneralInfoParcels.ToList())
            {
                var score = db.LandValuationScore.Where(m => m.GeneralinfoparcelID == general.Id).ToList();
                var total = 0;
                foreach (var scoreTotal in score)
                {
                    total = total + db.LandSettingTypeValues.Where(m => m.Id == scoreTotal.landsettingvalueID).FirstOrDefault().Value;
                }
                var rating = new RatingViewModel()
                {
                    id        = general.Id,
                    ParcelNo  = general.ParcelNo,
                    OwnerName = general.OwnerName,
                    Total     = total
                };
                RatingList.Add(rating);
                total = 0;
            }
            PagedList <RatingViewModel> models = new PagedList <RatingViewModel>(RatingList, page, pageSize);

            return(View(models));
        }
예제 #7
0
        public async Task <bool> UpdateRating(RatingViewModel _rating)
        {
            var rating = await this._context.Rating.SingleOrDefaultAsync(X => X.ApplicationUserId == _rating.ApplicationUserId && X.GivenUserId == _rating.GivenUserId);

            if (rating == null)
            {
                Rating newRating = new Rating
                {
                    Id                = new Guid(),
                    UserRating        = _rating.UserRating,
                    ApplicationUserId = _rating.ApplicationUserId,
                    GivenUserId       = _rating.GivenUserId,
                    UserComment       = _rating.UserComment
                };
                this._context.Add(newRating);
            }
            else
            {
                rating.UserRating = _rating.UserRating;
            }

            var result = await _context.SaveChangesAsync();

            return(result == 1);
        }
예제 #8
0
        public ActionResult Rating(int?themeId)
        {
            var testRepo = new TestRepository();
            var themes   = testRepo.GetAllThemes();

            ViewBag.Themes = themes;

            if (!themeId.HasValue || themeId == 0)
            {
                var viewUsers  = GetTestsRating();
                var viewRating = new RatingViewModel
                {
                    RatingName = Resources.Resource.MES_CommonRating,
                    Users      = viewUsers
                };
                return(View(viewRating));
            }

            var theme = testRepo.GetThemeInfo(themeId.Value);

            if (theme == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var viewUsers  = GetThemeRating(theme.ThemeID);
                var viewRating = new RatingViewModel
                {
                    RatingName = theme.ThemeName,
                    Users      = viewUsers
                };
                return(View(viewRating));
            }
        }
        // GET: Restaurants
        public async Task <IActionResult> Index(int restaurantRating, string searchString)
        {
            // Use LINQ to get list of genres.
            IQueryable <int> ratingQuery = from m in _context.Restaurant
                                           orderby m.Rating
                                           select m.Rating;

            var restaurants = from m in _context.Restaurant
                              select m;

            if (!string.IsNullOrEmpty(searchString))
            {
                restaurants = restaurants.Where(s => s.Name.Contains(searchString));
            }

            if (restaurantRating != 0)
            {
                restaurants = restaurants.Where(x => x.Rating == restaurantRating);
            }

            var restaurantRatingVM = new RatingViewModel
            {
                Ratings     = new SelectList(await ratingQuery.Distinct().ToListAsync()),
                Restaurants = await restaurants.ToListAsync()
            };

            return(View(restaurantRatingVM));
        }
        public ActionResult SupportingRatings()
        {
            string currentUserId = User.Identity.GetUserId();
            int    idInCourse    = db.Instructors.Where(c => c.ApplicationUserID == currentUserId).Select(c => c.ID)
                                   .FirstOrDefault();

            List <Course> courses = db.Courses.Where(c => c.InstructorID == idInCourse).ToList();
            //ViewBag.Courses = courses;

            List <RatingViewModel> nRatingsViewModels = new List <RatingViewModel>();
            RatingViewModel        temp = new RatingViewModel();

            foreach (var boxCourse in courses)
            {
                temp.NameCourse = boxCourse.Title;
                List <Module> mod = db.Modules.Where(c => c.CourseID == boxCourse.ID).ToList();
                temp.Modules = mod;
                nRatingsViewModels.Add(temp);
                temp = new RatingViewModel();
            }

            ViewBag.Courses = nRatingsViewModels;

            return(View());
        }
예제 #11
0
        public void Add(RatingViewModel viewModel)
        {
            var result = mapper.Map <Rating>(viewModel);

            unitOfWork.Add(result);
            unitOfWork.SaveChanges();
        }
예제 #12
0
        public ActionResult AddRating(RatingViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { success = false }));
            }
            var userid     = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();
            var userRating = new UserRatings {
                UserId = userid, CategoryItemID = model.ItemId, UserRating = Convert.ToDouble(model.Rating)
            };
            var ratedBefore = _db.UserRatings.Where(e => e.UserId == userid).FirstOrDefault(i => i.CategoryItemID == model.ItemId);

            if (ratedBefore != null)
            {
                _db.UserRatings.Remove(ratedBefore);
            }

            try
            {
                _db.UserRatings.Add(userRating);
                _db.UsersLastMoves.Add(new UsersLastMoves {
                    MoveDate = DateTime.Now, UserId = userRating.UserId, UsersLastMoveText = " bir öğeyi değerlendirdi.", UsersMoveLink = "/users/interests/" + userRating.UserId
                });
                _db.SaveChanges();
                return(Json(new { success = true }));
            }
            catch (Exception)
            {
                return(Json(new { success = false }));
            }
        }
예제 #13
0
    public virtual async Task <IViewComponentResult> InvokeAsync(string entityType, string entityId)
    {
        var ratings = await RatingPublicAppService.GetGroupedStarCountsAsync(entityType, entityId);

        var totalRating = ratings.Sum(x => x.Count);

        short?currentUserRating = null;

        if (CurrentUser.IsAuthenticated)
        {
            currentUserRating = ratings.Find(x => x.IsSelectedByCurrentUser)?.StarCount;
        }

        var loginUrl =
            $"{AbpMvcUiOptions.LoginUrl}?returnUrl={HttpContext.Request.Path.ToString()}&returnUrlHash=#cms-rating_{entityType}_{entityId}";

        var viewModel = new RatingViewModel
        {
            EntityId      = entityId,
            EntityType    = entityType,
            LoginUrl      = loginUrl,
            Ratings       = ratings,
            CurrentRating = currentUserRating,
            TotalRating   = totalRating
        };

        return(View("~/Pages/CmsKit/Shared/Components/Rating/Default.cshtml", viewModel));
    }
예제 #14
0
        public ActionResult Create(int id)
        {
            var context = new Context();
            var userId  = int.Parse(HttpContext.User.Identity.Name);
            var exist   = (from r in context.CarrierRating
                           join c in context.Carriers on r.CarrierId equals c.Id
                           where r.CarrierId == id &&
                           r.UserId == userId
                           select r).Any();

            if (exist)
            {
                return(RedirectToAction("Edit", new { id = id }));
            }

            var carrier = (from p in context.Carriers
                           where p.Id == id
                           select p).FirstOrDefault();

            if (carrier == null)
            {
                return(RedirectToAction("Index", "Carriers"));
            }
            var viewModel = new RatingViewModel
            {
                CarrierId   = carrier.Id,
                CarrierName = carrier.Name
            };

            return(View(viewModel));
        }
예제 #15
0
        public async Task <BaseReponse <ModelListResult <RatingViewModel> > > GetAllPaging(RateRequest request)
        {
            var query = (await _ratingRepository.FindAll()).AsNoTracking().AsParallel();

            if (request.ProductId > 0)
            {
                query = query.AsParallel().AsOrdered().WithDegreeOfParallelism(2).Where(x => x.ProductId == request.ProductId);
            }

            int totalRow = query.AsParallel().AsOrdered().WithDegreeOfParallelism(2).Count();

            query = query.AsParallel().AsOrdered().WithDegreeOfParallelism(2).OrderByDescending(x => x.DateCreated)
                    .Skip(request.PageIndex * request.PageSize)
                    .Take(request.PageSize);

            var items = new RatingViewModel().Map(query).ToList();

            return(new BaseReponse <ModelListResult <RatingViewModel> >
            {
                Data = new ModelListResult <RatingViewModel>()
                {
                    Items = items,
                    Message = Message.Success,
                    RowCount = totalRow,
                    PageSize = request.PageSize,
                    PageIndex = request.PageIndex
                },
                Message = Message.Success,
                Status = (int)QueryStatus.Success
            });
        }
 public RatingPage(int id)
 {
     InitializeComponent();
     EventId        = id;
     BindingContext = model = new RatingViewModel();
     // model.EventId = EventId;
 }
예제 #17
0
        public async Task <IActionResult> Rating(RatingViewModel rate)
        {
            rate.ProductId = HttpContext.Session.Get <int>(CommonConstants.ProductId);
            await _ratingService.Add(rate);

            return(new OkObjectResult(rate));
        }
예제 #18
0
        private List <RatingViewModel> GetRatingsFromCmd(OleDbCommand cmd)
        {
            var ratings = new List <RatingViewModel>();

            using (OleDbDataReader dbReader = cmd.ExecuteReader())
            {
                int _seasonYear   = dbReader.GetOrdinal("season_year");
                int _seasonPeriod = dbReader.GetOrdinal("season_period");
                int _regionName   = dbReader.GetOrdinal("region_name");
                int _className    = dbReader.GetOrdinal("class_name");
                int _classLevel   = dbReader.GetOrdinal("class_level");
                int _category     = dbReader.GetOrdinal("category");
                int _rating       = dbReader.GetOrdinal("rating");
                int _formula      = dbReader.GetOrdinal("formula");

                while (dbReader.Read())
                {
                    var rating = new RatingViewModel();

                    rating.seasonYear   = dbReader.GetInt32(_seasonYear);
                    rating.seasonPeriod = dbReader.GetInt32(_seasonPeriod);
                    rating.regionName   = dbReader.GetString(_regionName);
                    rating.className    = dbReader.GetString(_className);
                    rating.classLevel   = dbReader.GetInt32(_classLevel);
                    rating.category     = dbReader.GetInt32(_category);
                    rating.rating       = dbReader.GetInt32(_rating);
                    rating.formula      = dbReader.GetInt32(_formula);

                    ratings.Add(rating);
                }
            }

            return(ratings);
        }
예제 #19
0
        public async Task <ActionResult> AddRating(RatingViewModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(View(model));
            }

            var carrier = await(from t in _db.Carriers
                                where t.Active == true
                                where t.Id == model.CarrierId
                                select t).SingleOrDefaultAsync();

            if (carrier == null)
            {
                return(RedirectToAction("Index"));
            }

            var rating = new CarrierRating {
                CarrierId = model.CarrierId,
                UserId    = 1,
                Rating    = model.Rating
            };

            carrier.Ratings.Add(rating);

            _db.Entry(carrier).State = EntityState.Modified;

            int x = await _db.SaveChangesAsync();

            return(RedirectToAction("Details", new { id = model.CarrierId }));
        }
예제 #20
0
        public async Task <ActionResult> AddRating(RatingViewModel ratingVM)
        {
            if (ModelState.IsValid)
            {
                ratingVM.UserId = User.Identity.GetUserId();
                RatingDTO rDto = await ratingService.FindByUserIdAsync(ratingVM.UserId);

                if (rDto != null)
                {
                    await ratingService.DeleteByIdAsync(rDto.Id);
                }
                Mapper.Initialize(cfg => cfg.CreateMap <RatingViewModel, RatingDTO>());

                RatingDTO ratingDto = Mapper.Map <RatingViewModel, RatingDTO>(ratingVM);

                OperationDetails result = await ratingService.CreateAsync(ratingDto);

                RatingDTO r = await ratingService.FindByUserIdAsync(ratingVM.UserId);

                if (result.Succeeded)
                {
                    return(RedirectToAction("MyAlbums", "Album"));
                }
                else
                {
                    ModelState.AddModelError(result.Property, result.Message);
                }
            }
            return(View(ratingVM));
        }
        public async Task <IActionResult> Rate(RatingViewModel ratingViewModel)
        {
            var film = await _filmRepository.Get(ratingViewModel.FilmId);

            _filmRepository.Rate(film, ratingViewModel.Score);
            return(RedirectToAction("Details", new { url = ratingViewModel.EpisodeUrl }));
        }
        public async Task <ActionResult> ProductCard(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var product = await _productRepository.GetProductByID(id);

            ViewBag.Product = product;
            var sales = await _saleRepository.GetSales();

            Sale productSale = null;

            foreach (var sale in sales)
            {
                if (sale.Product == product)
                {
                    productSale = sale;
                    break;
                }
            }
            ViewBag.Sale = productSale;

            var comments = await _commentRepository.GetProductsLimit(product.ProductId, 5);

            ViewBag.Comments = comments;

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

            var rating = await _markRepository.GetMarkWhereId(product.ProductId);

            double ratingValue = 0;

            foreach (var value in rating)
            {
                ratingValue += value.TotalMark;
            }
            if (rating.Count() != 0)
            {
                ratingValue /= rating.Count();
            }

            int             fullStars       = (int)Math.Truncate(ratingValue);
            RatingViewModel ratingViewModel = new RatingViewModel
            {
                MarkCount   = rating.Count(),
                FullStars   = fullStars,
                HalfStar    = (ratingValue - fullStars) >= 0.5,
                EmptyStart  = (int)Math.Round((5 - ratingValue)),
                TotalRating = ratingValue
            };

            ViewBag.Rating = ratingViewModel;

            return(View(product));
        }
예제 #23
0
        public IActionResult Rating()
        {
            IEnumerable <Student> students = _repository.GetRatingStudents(DateTime.Now.Year, 0, 0);

            List <int>    years   = new List <int>();
            List <Course> courses = new List <Course>();

            foreach (Student student in students)
            {
                foreach (Listeners listener in student.Listeners)
                {
                    if (!years.Contains(listener.Course.Year))
                    {
                        years.Add(listener.Course.Year);
                    }

                    if (!courses.Contains(listener.Course))
                    {
                        courses.Add(listener.Course);
                    }
                }
            }

            RatingViewModel model = new RatingViewModel
            {
                Students = students,
                Years    = years,
                Courses  = courses
            };

            return(View(model));
        }
예제 #24
0
        public RatingViewModel CreateRatingModel(RatingViewModel viewModel, IEnumerable <Student> students)
        {
            List <int>    years   = new List <int>();
            List <Course> courses = new List <Course>();

            foreach (Student student in students)
            {
                foreach (Listeners listener in student.Listeners)
                {
                    if (!years.Contains(listener.Course.Year))
                    {
                        years.Add(listener.Course.Year);
                    }

                    if (!courses.Contains(listener.Course))
                    {
                        courses.Add(listener.Course);
                    }
                }
            }

            return(new RatingViewModel
            {
                Students = students,
                Years = years,
                Courses = courses
            });
        }
예제 #25
0
        public async Task <IActionResult> Rating(string id)
        {
            var viewModel = new RatingViewModel();

            viewModel.Name = await barService.GetNameForBarById(id);

            return(View(viewModel));
        }
예제 #26
0
        public async Task <RatingViewModel> Add(RatingViewModel ratingVm)
        {
            var page = new RatingViewModel().Map(ratingVm);
            await _ratingRepository.Add(page);

            _unitOfWork.Commit();
            return(ratingVm);
        }
예제 #27
0
 public Ratingpage()
 {
     //LoadingIndicatorHelper.Intialize(this);
     rate = new List <RatingModel>();
     InitializeComponent();
     BindingContext      = new RatingViewModel(Navigation);
     constants.mysubmits = new List <RatinganswerModel>();
 }
        public void DeleteRating(RatingViewModel model)
        {
            Guid lessonId = database.IdMaps.GetAggregateId<Lesson>(model.LessonId);
            Guid ratingId = database.IdMaps.GetAggregateId<LessonRating>(model.Id.Value);
            DateTime date = model.Date == null ? DateTime.Now : model.Date.Value;

            bus.Send<DeleteRatingCommand>(new DeleteRatingCommand(lessonId, ratingId, date, model.Vers));
        }
예제 #29
0
        public void Edit(RatingViewModel viewModel)
        {
            Rating rating = unitOfWork.Get <Rating>(viewModel.Id);

            mapper.Map(viewModel, rating);
            unitOfWork.Update(rating);
            unitOfWork.SaveChanges();
        }
예제 #30
0
        // GET: Rating
        public ActionResult Index()
        {
            var ratingViewModel = new RatingViewModel();

            ratingViewModel.SetCarriersToRatingList(_ratingService.GetCarrierToRating(base.UserBase.GetStringId()));
            ratingViewModel.SetRatingsList(_ratingService.GetRatingByUserId(base.UserBase.GetStringId()));
            return(View(ratingViewModel));
        }
        public IActionResult GetByProduct(int id)
        {
            var Rating = new RatingViewModel();

            Rating.Ratings        = _ratingRepository.GetByProductId(id);
            Rating.AverageRatings = Rating.Ratings.Average(r => r.Rate);
            return(Ok(Rating));
        }
        public void AddNewRating(RatingViewModel model)
        {
            Guid lessonId = database.IdMaps.GetAggregateId<Lesson>(model.LessonId);
            Guid authorId = database.IdMaps.GetAggregateId<User>(model.Author.UserId);
            DateTime date = model.Date == null ? DateTime.Now : model.Date.Value;

            var command = new AddNewRatingCommand(lessonId, authorId, model.Rating, model.Content, date, model.Vers);
            bus.Send<AddNewRatingCommand>(command);
            model.Id = database.IdMaps.GetModelId<LessonRating>(command.RatingId);
        }
예제 #33
0
        public Design()
        {
            var foodService = new DesignFoodService();
            var meal = foodService.GetMenusAsync( null, CancellationToken.None ).Result.Menu[0].Meals[0];

            Main = new MainViewModel( new DesignDataCache(), new DesignNavigationService(), new DesignFoodService(),
                                      new DesignCredentialsStorage(), new DesignPluginSettings() );
            Rating = new RatingViewModel( new DesignFoodService(), new DesignNavigationService(), new DesignDeviceIdentifier(), meal );
            Settings = new SettingsViewModel( new DesignPluginSettings() );

            Main.OnNavigatedToAsync();
            Rating.OnNavigatedToAsync();
            Settings.OnNavigatedTo();
        }
예제 #34
0
 public IHttpActionResult DeleteLessonRating(int id, RatingViewModel rating)
 {
     if (!ModelState.IsValid)
     {
         return BadRequest(ModelState);
     }
     try
     {
         CommandWorker.DeleteRating(rating);
         return RedirectToRoute("GetRatingById", new { id = rating.Id.Value });
     }
     catch (Exception e)
     {
         return BadRequest(e.Message);
     }            
 }