コード例 #1
0
 public ActionResult ModifierRestaurant(int id, Restaurant poRestau)
 {
     if (ModelState.IsValid)
     {
         dal.ModifierRestaurant(poRestau.Id, poRestau.Nom, poRestau.Adresse, poRestau.Telephone, poRestau.Email);
         return RedirectToAction("AfficherRestaurant", new { id = poRestau.Id });
     }
     return View();
 }
コード例 #2
0
ファイル: Dal.cs プロジェクト: ColinPeyrat/asp.net-mvc
        public int CreerRestaurant(string nom, string adresse, string telephone, string email)
        {
            
            Restaurant restaurant = new Restaurant() 
            { 
                Nom=nom,
                Adresse=adresse,
                Telephone=telephone,
                Email=email
            };

            sctx.Restaurants.Add(restaurant);
            sctx.SaveChanges();
          
            return restaurant.Id;
        }
コード例 #3
0
        public ActionResult CreerRestaurant(Restaurant poResto)
        {

            if (dal.RestaurantExist(poResto.Nom))
            {
                ModelState.AddModelError(string.Empty, "Ce restaurant existe déja");
            }
            if (ModelState.IsValid)
            {
                dal.CreerRestaurant(poResto.Nom, poResto.Adresse, poResto.Telephone, poResto.Email);
                return RedirectToAction("index");
            }
            else
            {
                return View();
            }
           
        }