Esempio n. 1
0
        public async Task <IActionResult> Reset(Guid eventId)
        {
            var target = await GetEventById(eventId);

            if (target == null)
            {
                return(RedirectToAction("Index", "Dashboard"));
            }

            _context.RemoveRange(target.Votes.SelectMany(x => x.Choices));
            _context.RemoveRange(target.Votes);

            target.StartDate = target.EndDate = null;

            _context.SaveChanges();

            return(RedirectToAction("Index", "Dashboard"));
        }
Esempio n. 2
0
        public IActionResult RemoveOption(Guid optionId, Guid eventId)
        {
            var option = new Option
            {
                ID = optionId
            };

            _context.Options.Attach(option);
            _context.Options.Remove(option);

            var tokens = _context.Tokens.Where(x => x.OptionID == optionId);

            _context.RemoveRange(tokens);

            _context.SaveChanges();

            return(RedirectToAction("Edit", "Event", new
            {
                eventId,
                section = "options"
            }));
        }