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

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SkillExists(Skill.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #2
0
        public async Task <IActionResult> OnPostAsync(int?id, string[] selectedSkills)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var experienceToUpdate = await _context.Experience
                                     .Include(i => i.ExperienceSkills)
                                     .FirstOrDefaultAsync(s => s.ID == id);

            if (await TryUpdateModelAsync <Experience>(
                    experienceToUpdate,
                    "Experience",
                    i => i.Title, i => i.Organization,
                    i => i.Location, i => i.Dates,
                    i => i.Type, i => i._desc
                    ))
            {
                UpdateInstructorCourses(_context, selectedSkills, experienceToUpdate);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            UpdateInstructorCourses(_context, selectedSkills, experienceToUpdate);
            PopulateAssignedCourseData(_context, experienceToUpdate);
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Skill.Add(Skill);
            await _context.SaveChangesAsync();

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

            Experience = await _context.Experience.FindAsync(id);

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

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

            Skill = await _context.Skill.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(string[] selectedSkills)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var newExperience = new Experience();

            if (selectedSkills != null)
            {
                newExperience.ExperienceSkills = new List <ExperienceSkill>();
                foreach (var skill in selectedSkills)
                {
                    var skillToAdd = new ExperienceSkill
                    {
                        SkillId = int.Parse(skill)
                    };
                    newExperience.ExperienceSkills.Add(skillToAdd);
                }
            }
            if (await TryUpdateModelAsync <Experience>(
                    newExperience,
                    "Experience"))
            {
                _context.Experience.Add(newExperience);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            PopulateAssignedCourseData(_context, newExperience);

            //_context.Experience.Add(Experience);
            //await _context.SaveChangesAsync();

            return(Page());
        }