Example #1
0
        public async Task <IActionResult> PutRating(int id, Rating rating)
        {
            if (id != rating.Id)
            {
                return(BadRequest());
            }

            _context.Entry(rating).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RatingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("ID,Name,PassCode")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
        public async Task <IActionResult> Create([Bind("Id,DeptId,QuestionNo,Point,Comment,DateTime")] Rating rating)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rating);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rating));
        }
Example #4
0
        public async Task <IActionResult> Add(Rating rating)
        {
            _dbContext.Ratings.Add(rating);
            await _dbContext.SaveChangesAsync();

            var ratings = await _dbContext.Ratings.ToListAsync();

            return(View("Index", ratings));
        }
        public async Task <IActionResult> Rate([Bind("DeptId,Point,Comment")] Rating rating)
        {
            if (ModelState.IsValid)
            {
                rating.DateTime = DateTime.UtcNow;
                _context.Ratings.Add(rating);
                await _context.SaveChangesAsync();

                return(View("RateComplete", rating));
            }
            return(View("Rate"));
        }