public async Task <IActionResult> Create([FromBody][Bind("NbHtotalCompetence,CodeCompetence,ValidationApprouve,NoProgramme")] RepartirHeureCompetence repartirHeureCompetence) { try { repartirHeureCompetence.NoProgramme = this.HttpContext.Session.GetString("programme"); if (ModelState.IsValid) { _context.Add(repartirHeureCompetence); await _context.SaveChangesAsync(); return(Ok("ajout reussi")); } ViewData["CodeCompetence"] = new SelectList(_context.Competences.Where(x => x.NoProgramme.Equals(this.HttpContext.Session.GetString("programme"))), "CodeCompetence", "CodeCompetence", repartirHeureCompetence.CodeCompetence); return(BadRequest("groupe non ajouté")); } catch (Exception e) { return(View("\\Views\\Shared\\page_erreur.cshtml")); } }
public async Task <IActionResult> Edit(string id, [Bind("NbHsessionCompetence,CodeCompetence,NomSession,ValidationApprouve,NoProgramme")] RepartirHeureCompetence repartirHeureCompetence) { try { if (id != repartirHeureCompetence.CodeCompetence) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(repartirHeureCompetence); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RepartirHeureCompetenceExists(repartirHeureCompetence.CodeCompetence)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(ListeRepartirHeureCompetences))); } ViewData["CodeCompetence"] = new SelectList(_context.Competences.Where(x => x.NoProgramme.Equals(this.HttpContext.Session.GetString("programme"))), "CodeCompetence", "CodeCompetence", repartirHeureCompetence.CodeCompetence); return(View(repartirHeureCompetence)); } catch (Exception e) { return(View("\\Views\\Shared\\page_erreur.cshtml")); } }