Ejemplo n.º 1
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"));
        }
        public async Task <IActionResult> OnPostAsync(long id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            Message      = "Skill saved";
            MessageAlert = "success";
            return(RedirectToPage());
        }