Beispiel #1
0
        public async Task <IActionResult> OnPostDeleteAsync(long id)
        {
            var skill = await _context.Skill.FindAsync(id);

            if (skill != null)
            {
                _context.Skill.Remove(skill);
                await _context.SaveChangesAsync();
            }
            return(RedirectToPage());
        }
Beispiel #2
0
        public async Task <IActionResult> OnPostDeleteAsync(long id)
        {
            var contact = await _context.Character.FindAsync(id);

            if (contact != null)
            {
                _context.Character.Remove(contact);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage());
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Character.Add(CharacterSkill);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Beispiel #4
0
        public async Task <IActionResult> OnPostAsync(long id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _larpBuilderContext.Attach(Character).State = EntityState.Modified;
            try
            {
                await _larpBuilderContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                Console.WriteLine("A DBUpdateConcurrencyException was thrown.");
                throw new Exception("Character " + Character.Id + " not found!");
            }

            Message      = "Name saved";
            MessageAlert = "success";
            return(RedirectToPage());
        }
Beispiel #5
0
        public async Task <IActionResult> OnPostAsync(long id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _larpBuilderContext.Attach(CharacterSkill).State = EntityState.Modified;
            try
            {
                await _larpBuilderContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                Console.WriteLine("A DBUpdateConcurrencyException was thrown.");
                throw new Exception("The Character with CharacterId: +" + CharacterSkill.CharacterId + " does not have a skill with Skill ID: " + CharacterSkill.SkillId);
            }

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