Beispiel #1
0
        public ActionResult CreateEdit(InscriptionViewModel inscriptionVm)
        {
            /*
             * //on instancie un objetBD à partir du view model récupéré en param
             * //si le modelstate est valide
             * //on crée une course
             * //on redirige à la page index
             * //sinon on retourne la view avec le view model de course
             */
            Inscription inscription = this._repository.Get(inscriptionVm.Id);

            if (ModelState.IsValid)
            {
                if (inscription == null)
                {
                    inscription = new Inscription();
                    this._repository.Create(inscription);
                }

                inscriptionVm.Map(inscription);
                inscription.dateInscription = DateTime.Now;
                inscription.UtilisateurName = User.Identity.Name;

                this._repository.Commit();
                return(RedirectToAction(nameof(this.Index)));
            }
            return(View("CreateEdit", inscriptionVm));
        }
        // GET: Inscriptions
        public ActionResult Index(InscriptionViewModel vm)
        {
            vm.Inscriptions = db.Inscriptions.Where(i => i.DateDeleted == null).ToList();
            var groups = db.Inscriptions.AsEnumerable().GroupBy(i => i.DateAdded.ToString("M"));

            vm.DateSelectList = new SelectList(groups.Select(g => g.Key));
            return(View(vm));
        }
        public IActionResult Create()
        {
            var inscriptionViewModel = new InscriptionViewModel();

            inscriptionViewModel.Careers = new SelectList(_careerService.GetAll(), "Id", "Name");
            inscriptionViewModel.Years   = new SelectList(_yearService.GetAll(), "Id", "Name");
            inscriptionViewModel.Matters = new List <SelectListItem>();
            inscriptionViewModel.Courses = new List <SelectListItem>();
            return(View(inscriptionViewModel));
        }
 public ActionResult Edit(InscriptionViewModel vm)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vm.Inscription).State = EntityState.Modified;
         vm.Inscription.DateModified    = DateTime.Now;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(vm));
 }
        public ActionResult Create(InscriptionViewModel inscVM)
        {
            if (ModelState.IsValid)
            {
                db.Inscriptions.Add(inscVM.Inscription);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(inscVM));
        }
        public ActionResult Create(InscriptionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                vm.Inscription.DateAdded = DateTime.Now;
                db.Inscriptions.Add(vm.Inscription);
                db.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }

            return(View(vm));
        }
        // GET: Inscriptions/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var vm = new InscriptionViewModel {
                Inscription = db.Inscriptions.Find(id)
            };

            if (vm.Inscription == null)
            {
                return(HttpNotFound());
            }
            return(View(vm));
        }
 public IActionResult Inscription(InscriptionViewModel newUser)
 {
     if (ModelState.IsValid && !_context.User.Any(p => p.Mail == newUser.Mail))
     {
         var user = new User();
         user.Mail     = newUser.Mail;
         user.Password = newUser.Password;
         _context.User.Add(user);
     }
     else
     {
         if (_context.User.Any(p => p.Mail == newUser.Mail))
         {
             ModelState.AddModelError("Bad", "Le mail est déja utilisé");
         }
         return(View());
     }
     return(RedirectToAction(nameof(Index)));
 }
        public IActionResult Create(InscriptionViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var course        = _courseService.GetById(model.CourseId);
            var currentUserId = HttpContext.Session.GetInt32("_Id").Value;

            if (_inscriptionService.ValidateSubscribe(course.Id, currentUserId))
            {
                _inscriptionService.CreateSubcribe(course, currentUserId);

                return(RedirectToAction("Index", "Student", model.CourseId));
            }

            return(BadRequest("Ya se encuentra registrado"));
        }
 public ActionResult Inscription(MembreModel form)
 {
     if (ModelState.IsValid) //validation coté serveur vs. annotations
     {
         DataContext ctx = new DataContext(ConfigurationManager.ConnectionStrings["Cnstr"].ConnectionString);
         if (ctx.CreateMember(form))
         {
             ViewBag.SuccessMessage = "Votre demande d'inscription a bien été envoyée";
             return(RedirectToAction("Index", "Home", new { area = "Membre" }));
         }
         else
         {
             ViewBag.ErrorMessage = "Message non enregistré";
             return(View());
         }
     }
     else
     {
         ViewBag.ErrorMessage = "Formulaire error : vérifiez les données insérées et réessayez";
         InscriptionViewModel ivm = new InscriptionViewModel();
         return(View(ivm));
     }
 }
        public ActionResult Inscription()
        {
            InscriptionViewModel ivm = new InscriptionViewModel();

            return(View(ivm));
        }
        // GET: Inscriptions/Create
        public ActionResult Create()
        {
            var vm = new InscriptionViewModel();

            return(View(vm));
        }
Beispiel #13
0
 public InscriptionPage()
 {
     InitializeComponent();
     NavigationPage.SetHasBackButton(this, false);
     BindingContext = new InscriptionViewModel();
 }
Beispiel #14
0
 public InscriptionWindow()
 {
     InitializeComponent();
     DataContext = new InscriptionViewModel();
     ((ViewModelBase)DataContext).CloseAction = () => this.Close();
 }
Beispiel #15
0
 public Inscription(Course course, ListView listView)
 {
     InitializeComponent();
     BindingContext = new InscriptionViewModel(course, listView, Navigation);
 }
Beispiel #16
0
 public InscriptionView()
 {
     InitializeComponent();
     BindingContext = new InscriptionViewModel();
 }
Beispiel #17
0
 public Inscription()
 {
     InitializeComponent();
     ViewModel   = new InscriptionViewModel(this);
     DataContext = ViewModel;
 }