public ActionResult Edit(RestaurantsEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                UsersRepository rep = new UsersRepository();
                ViewBag.ManagerId = new SelectList(rep.GetAll(), "Id", "Name");
                return(View());
            }
            Restaurant rest = new Restaurant();

            rest.Id        = model.Id;
            rest.ManagerId = model.ManagerId;
            rest.Name      = model.Name;
            rest.OpenHour  = model.OpenHour;
            rest.CloseHour = model.CloseHour;
            rest.Capacity  = model.Capacity;
            rest.Email     = model.Email;
            rest.Phone     = model.Phone;
            rest.Address   = model.Address;
            RestaurantsRepository repo = new RestaurantsRepository();

            repo.Update(rest);

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Edit(int?id)
        {
            RestaurantRepository repository = new RestaurantRepository();

            RestaurantsEditViewModel model = new RestaurantsEditViewModel();

            if (id.HasValue)
            {
                Restaurant restaurant = repository.GetByID(id.Value);
                model.ID        = restaurant.ID;
                model.Name      = restaurant.Name;
                model.Address   = restaurant.Address;
                model.Phone     = restaurant.Phone;
                model.Capacity  = restaurant.Capacity;
                model.OpenHour  = restaurant.OpenHour;
                model.CloseHour = restaurant.CloseHour;
            }

            return(View(model));
        }
        public ActionResult Edit(int Id)
        {
            RestaurantsRepository repo         = new RestaurantsRepository();
            Restaurant            dbrestaurant = new Restaurant();

            dbrestaurant = repo.Get(Id);
            RestaurantsEditViewModel model = new RestaurantsEditViewModel();

            model.Address   = dbrestaurant.Address;
            model.Capacity  = dbrestaurant.Capacity;
            model.Email     = dbrestaurant.Email;
            model.Name      = dbrestaurant.Name;
            model.Phone     = dbrestaurant.Phone;
            model.OpenHour  = dbrestaurant.OpenHour;
            model.ManagerId = dbrestaurant.ManagerId;
            model.CloseHour = dbrestaurant.CloseHour;
            model.Id        = Id;
            UsersRepository rep = new UsersRepository();

            ViewBag.ManagerId = new SelectList(rep.GetAll(), "Id", "Name");
            return(View(model));
        }
Beispiel #4
0
        public ActionResult Edit(RestaurantsEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            RestaurantRepository repository = new RestaurantRepository();

            Restaurant restaurant = new Restaurant();

            restaurant.ID        = model.ID;
            restaurant.Name      = model.Name;
            restaurant.Address   = model.Address;
            restaurant.Phone     = model.Phone;
            restaurant.Capacity  = model.Capacity;
            restaurant.OpenHour  = model.OpenHour;
            restaurant.CloseHour = model.CloseHour;

            repository.Save(restaurant);

            return(RedirectToAction("Index"));
        }