Пример #1
0
        public IActionResult Edit(RegionViewModels regionModel)
        {
            RegionContext regionContext = new RegionContext(connectionString);

            regionModel.Region = regions();
            //Rajouter des contrôles dynamiques

            //if(bugModel.IdentifiantSeverite == 2)
            //{
            //    ModelState.AddModelError("IdentifiantSeverite", "Ne peut être égal à 2");
            //}

            IActionResult retour = null;

            if (ModelState.IsValid)
            {
                Region region = new Region();

                region.Identifiant = (int)regionModel.Identifiant;
                region.Nom         = regionModel.Nom;


                bool isOK = regionContext.Update(region);
                retour = RedirectToAction("Index");
            }
            else
            {
                retour = View(regionModel);
            }

            return(retour);
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("region_id,country_id,name")] Region region)
        {
            if (id != region.region_id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(region);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RegionExists(region.region_id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(region));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("RegionID,Id,Name,ResourceTypeId,Lng,Lat,Description,URL")] Resource resource)

        {
            if (id != resource.Id)

            {
                return(NotFound());
            }



            if (ModelState.IsValid)

            {
                try

                {
                    _context.Update(resource);

                    await _context.SaveChangesAsync();
                }

                catch (DbUpdateConcurrencyException)

                {
                    if (!ResourceExists(resource.Id))

                    {
                        return(NotFound());
                    }

                    else

                    {
                        throw;
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(resource));
        }