Esempio n. 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Survey).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SurveyExists(Survey.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostVoteAsync(int?id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            try
            {
                PointedOption = await _context.SurveyOptions.FindAsync(id);

                PointedOption.Point += 1;
                _context.Attach(PointedOption).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SurveyOptionExists(PointedOption.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("/Surveys/Index"));
        }
Esempio n. 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.SurveyOptions.Add(SurveyOption);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Esempio n. 4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SurveyOption = await _context.SurveyOptions.FindAsync(id);

            if (SurveyOption != null)
            {
                _context.SurveyOptions.Remove(SurveyOption);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }