public ActionResult RateInstructor(int id)
        {
            var service = GetBrowsingService();

            ViewBag.Detail = service.GetInstructorById(id);

            var model = new InstructorRatingCreate {
                InstructorId = id
            };

            return(View(model));
        }
 public ActionResult RateInstructor(InstructorRatingCreate model)
 {
     if (ModelState.IsValid)
     {
         var service = new RatingService(User.Identity.GetUserId());
         if (service.CreateInstructorRating(model))
         {
             return(RedirectToAction(nameof(Index)));
         }
     }
     return(View(model));
 }
Example #3
0
        public ActionResult Rate(int id)
        {
            var service = GetInstructorService();

            ViewBag.Detail = service.GetInstructorById(id);
            var entity = service.GetInstructorById(id);
            var model  = new InstructorRatingCreate {
                InstructorId = entity.InstructorId
            };

            return(View(model));
        }
        public bool CreateInstructorRating(InstructorRatingCreate model)
        {
            var ctx       = new ApplicationDbContext();
            var createdBy = ctx.Users.FirstOrDefault(u => u.Id == _userId).UserName;
            var entity    = new InstructorRating
            {
                Description  = model.Description,
                InstructorId = model.InstructorId,
                Score        = model.Score,
                //FullName = model.FullName,
                //ProgramId = model.ProgramId,
                //AcademyId = model.AcademyId,
                //AcademyName = model.AcademyName,
                OwnerId   = _userId,
                CreatedBy = createdBy
            };

            ctx.Ratings.Add(entity);
            return(ctx.SaveChanges() == 1);
            //_context.Ratings.Add(entity);
            //var changeCount = _context.SaveChangesAsync();

            //return changeCount == 1;
        }