public async Task <IActionResult> Edit(int id, [Bind("CourId,name,EnseignantId,SalleId")] Cour cour)
        {
            if (id != cour.CourId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cour);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourExists(cour.CourId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EnseignantId"] = new SelectList(_context.Enseignants, "EnseignantId", "cin", cour.EnseignantId);
            ViewData["SalleId"]      = new SelectList(_context.Salles, "SalleId", "SalleId", cour.SalleId);
            return(View(cour));
        }
 public PageAjouterCours(Cour a)
 {
     InitializeComponent();
     WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
     txt_Nom.Text          = a.nomCours;
     cb_Finis.IsChecked    = a.estFinit;
     d_Date.SelectedDate   = a.dateCours;
     using (var db = new MarcassinEntities1()) {
         cmb_Competence.ItemsSource       = db.Competences.ToList();
         cmb_Competence.DisplayMemberPath = "nomCompetence";
         cmb_Competence.SelectedValuePath = "idCompetence";
         int index = 0;
         for (int i = 0; i < cmb_Competence.Items.Count; i++)
         {
             List <Competence> parts = db.Competences.ToList();
             if (parts[i].nomCompetence == a.Competence.nomCompetence)
             {
                 index = i;
             }
         }
         this.cmb_Competence.SelectedIndex = index;
     }
     Id     = a.idCours;
     Action = "update";
     Btn_ajouter.Content    = "Modifier";
     Btn_ajouter.Background = new SolidColorBrush(Color.FromRgb(255, 200, 0));
 }
Example #3
0
        public ActionResult Insert(Cours model)
        {
            //var idCours = (from x in context.Cours where x.Nom == model.Nom select x.Nom).Single();

            Cour insertion = new Cour
            {
                Nom         = model.Nom,
                Description = model.Description,
                Prerequis   = model.Prerequis,
                NbModules   = model.NbModules,
                Content     = model.Content
            };

            context.Cours.InsertOnSubmit(insertion);
            try
            {
                context.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                context.SubmitChanges();
            }

            return(View(model));
        }
Example #4
0
 public void SupprCours(Cour a)
 {
     using (var db = new MarcassinEntities1()) {
         Cour b = db.Cours.Find(a.idCours);
         db.Cours.Remove(b);
         db.SaveChanges();
     }
 }
        public ActionResult Editcour()
        {
            int?id = Convert.ToInt32(TempData["editcour"]);
            Repository <Cour> _repradbtn = new Repository <Cour>(AppConfig.DbConnexionString);
            Cour cour = _repradbtn.GetSingle(v => v.IdCour == id, false);

            return(View(cour));
        }
        public ActionResult AddCours(string Title, string Education, string Chapters, string Date, string Description, string Image)
        {
            niveauEducationDataClassesDataContext db = new niveauEducationDataClassesDataContext();
            Cour c1 = new Cour {
                idprof = Convert.ToInt32(Session["id"]), titre = Title, niveaueducation = Education, chapitres = Chapters,
                date   = Date, description = Description, image = Image
            };                                              //fetch IDPROF

            db.Cours.InsertOnSubmit(c1);
            db.SubmitChanges();

            return(View("AddCourse"));
        }
        public async Task <IActionResult> Create([Bind("CourId,name,EnseignantId,SalleId")] Cour cour)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cour);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EnseignantId"] = new SelectList(_context.Enseignants, "EnseignantId", "cin", cour.EnseignantId);
            ViewData["SalleId"]      = new SelectList(_context.Salles, "SalleId", "SalleId", cour.SalleId);
            return(View(cour));
        }
Example #8
0
 public ActionResult Delete(Cours cour)
 {
     try
     {
         Cour unCours = context.Cours.Where(x => x.Nom == cour.Nom).Single <Cour>();
         context.Cours.DeleteOnSubmit(unCours);
         context.SubmitChanges();
         return(Redirect("Admin"));
     }
     catch
     {
         return(View(cour));
     }
 }
        public ActionResult Editcour(Cour cour)
        {
            Repository <Cour> _repradbtn = new Repository <Cour>(AppConfig.DbConnexionString);

            if (ModelState.IsValid)
            {
                _repradbtn.Update(cour);

                return(RedirectToAction("Index"));
            }


            return(View(cour));
        }
        public ActionResult DeleteConfirmed1()
        {
            int?id = Convert.ToInt32(TempData["deletcour1"]);
            Repository <Cour> _reptoutabs1 = new Repository <Cour>(AppConfig.DbConnexionString);


            Cour cour = _reptoutabs1.GetSingle(v => v.IdCour == id, false);

            _reptoutabs1.Delete(cour);



            return(RedirectToAction("Index"));
        }
        public ActionResult Detailscour(int id)
        {
            int idcou = id;

            Repository <Cour> repadmin3 = new Repository <Cour>(AppConfig.DbConnexionString);
            Cour lis1 = repadmin3.GetSingle(v => v.IdCour == idcou, false);

            if (lis1 == null)
            {
                return(HttpNotFound());
            }

            return(View(lis1));
        }
Example #12
0
        public async Task <IActionResult> OnGetAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Cour = await _context.Cours.FirstOrDefaultAsync(m => m.nom == id);

            if (Cour == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public ActionResult Deletecour(bool?saveChangesError)
        {
            int?id = Convert.ToInt32(TempData["deletcour"]);
            Repository <Cour> _reptoutabs1 = new Repository <Cour>(AppConfig.DbConnexionString);



            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Unable to save changes. Try again, and if the problem persists see your system administrator.";
            }
            Cour cour = _reptoutabs1.GetSingle(v => v.IdCour == id, false);

            TempData["deletcour1"] = id;
            return(View(cour));
        }
        public ActionResult DetailEnseignant(int id)
        {
            int idcou = id;

            Repository <Enseignant> repadmin3 = new Repository <Enseignant>(AppConfig.DbConnexionString);
            Enseignant        lis1            = repadmin3.GetSingle(v => v.Idenseignant == idcou, false);
            Repository <Cour> repetudiant     = new Repository <Cour>(AppConfig.DbConnexionString);
            Cour cour = repetudiant.GetSingle(v => v.IdCour == lis1.IdCour, false);

            ViewBag.libelcour = cour.Libelle;
            if (lis1 == null)
            {
                return(HttpNotFound());
            }

            return(View(lis1));
        }
Example #15
0
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Cour = await _context.Cours.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Example #16
0
 private void Btn_Modifier(object sender, RoutedEventArgs e)
 {
     if (Lv_chat.SelectedItem != null)
     {
         string table = lblTables.Content as string;
         Cour   c     = Lv_chat.SelectedItem as Cour;
         Window a     = new PageAjouterChatRoom(c.ChatRoom)
         {
             Title = "Modifier ChatRoom",
         };
         a.Show();
     }
     else
     {
         Erreur er = new Erreur("Veuillez selectionner une ChatRoom pour pouvoir le modifier");
         er.Show();
     }
 }
Example #17
0
 public void InsertCours(string Nom, DateTime Date, bool?Finis, Competence Comp)
 {
     using (var db = new MarcassinEntities1()) {
         string name = Nom + " ChatRoom";
         db.ChatRooms.Add(new ChatRoom()
         {
             nomduRoom = name
         });
         db.SaveChanges();
         ChatRoom cr = db.ChatRooms.Where(m => m.nomduRoom == name).First();
         Cour     c  = new Cour()
         {
             nomCours = Nom, dateCours = Date, estFinit = Finis.Value, Competence = Comp, ChatRoom = cr
         };
         db.Cours.Add(c);
         db.SaveChanges();
     }
 }
Example #18
0
 public ActionResult Update(Cours model)
 {
     try
     {
         Cour cour = context.Cours.Where(x => x.Nom == model.Nom).Single <Cour>();
         cour.Nom         = model.Nom;
         cour.Description = model.Description;
         cour.Prerequis   = model.Prerequis;
         cour.NbModules   = model.NbModules;
         cour.Content     = model.Content;
         context.SubmitChanges();
         return(RedirectToAction("Admin"));
     }
     catch
     {
         return(View(model));
     }
 }
        public ActionResult ajoutercour(Cour tt)
        {
            Repository <Cour> _repradbtn = new Repository <Cour>(AppConfig.DbConnexionString);



            try
            {
                if (ModelState.IsValid)
                {
                    _repradbtn.Add(tt);
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return(View(tt));
        }
Example #20
0
 public void ModifyCours(int Id, string Nom, DateTime Date, bool?Finis, Competence Comp)
 {
     using (var db = new MarcassinEntities1()) {
         Cour b = db.Cours.Find(Id);
         b.nomCours  = Nom;
         b.dateCours = Date;
         if (Finis == null)
         {
             b.estFinit = false;
         }
         else
         {
             b.estFinit = true;
         }
         b.Competence = db.Competences.Find(Comp.idCompetence);
         ChatRoom cr = db.ChatRooms.Find(b.ChatRoom.idChatRoom);
         string   n  = Nom + " ChatRoom";
         cr.nomduRoom       = n;
         db.Entry(cr).State = EntityState.Modified;
         db.Entry(b).State  = EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #21
0
 public Season(Anime a)
 {
     Quarter = GetCour(a.StartDate);
     Year    = a.StartDate.Year;
 }
Example #22
0
 public CoursesListViewModel()
 {
     Messenger.Default.Register <NotificationMessage>(this, (message) =>
     {
         switch (message.Notification)
         {
         case "NewCourse":
             SelectedCourse = new Cour()
             {
                 C_id = -1
             };
             break;
         }
     });
     Messenger.Default.Register <NotificationMessage>(this, (message) =>
     {
         switch (message.Notification)
         {
         case "DeleteCourse":
             if (SelectedCourse != null)
             {
                 var mres = MessageBox.Show("Supprimer Cour", "Vous etes Sur ?", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                 if (mres == MessageBoxResult.Yes)
                 {
                     _dbContext.Cours.Remove(_dbContext.Cours.Find(SelectedCourse.C_id));
                     _dbContext.SaveChanges();
                     ListCourses = new ObservableCollection <Cour>(_dbContext.Cours);
                 }
             }
             else
             {
                 var mres = MessageBox.Show("Selectionner un cour a supprimer ?", "Supprimer Cour", MessageBoxButton.OK, MessageBoxImage.Error);
             }
             break;
         }
     });
     SearchItems = new ObservableCollection <SearchItem>()
     {
         new SearchItem()
         {
             IsSelected = true,
             Name       = "Code"
         },
         new SearchItem()
         {
             IsSelected = true,
             Name       = "Intitule"
         },
         new SearchItem()
         {
             IsSelected = true,
             Name       = "Duree"
         },
         new SearchItem()
         {
             IsSelected = true,
             Name       = "Niveau"
         },
         new SearchItem()
         {
             IsSelected = true,
             Name       = "Annee"
         },
         new SearchItem()
         {
             IsSelected = true,
             Name       = "Description"
         },
         new SearchItem()
         {
             IsSelected = true,
             Name       = "Categorie"
         }
         ,
         new SearchItem()
         {
             IsSelected = true,
             Name       = "Technology"
         }
     };
     foreach (var item in SearchItems)    //DirtyCode * Needs Optimisation
     {
         item.PropertyChanged += UpdateSearchTerms;
     }
     _worker.DoWork             += LoadCourses;
     _worker.RunWorkerCompleted += LoadCoursesCompleted;
     _worker.RunWorkerAsync();
 }
Example #23
0
 public bool update(Cour entity)
 {
     db.SaveChanges();
     return(true);
 }
Example #24
0
 public bool create(Cour entity)
 {
     db.Cours.Add(entity);
     return(db.SaveChanges() > 0);
 }
        public ActionResult EditeCour(int id)
        {
            Cour cour = dao.getById(id);

            return(View(cour));
        }
Example #26
0
 public Season(Manga m)
 {
     Quarter = GetCour(m.StartDate);
     Year    = m.StartDate.Year;
 }
 public ActionResult AddCour(Cour cour)
 {
     dao.create(cour);
     return(RedirectToAction("Index"));
 }