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")); }
public RestaurantsController(IConfigurationRoot configuration, RestaurantsRepository restaurantsRepository, RestaurantsSearchService restaurantsSearchService) { _restaurantsRepository = restaurantsRepository; _restaurantsSearchService = restaurantsSearchService; _configuration = configuration; }
public ActionResult Delete(Restaurant restaurant) { RestaurantsRepository rep = new RestaurantsRepository(); rep.Delete(restaurant); return(RedirectToAction("Index")); }
public static void DeleteMany() { var restRepo = new RestaurantsRepository(); var restaurant = restRepo.GetAll().Where(b => b.Name.StartsWith("Kitchen")).ToList(); restRepo.DeleteRange(restaurant); restRepo.Save();; }
public ActionResult Index() { RestaurantsRepository repository = new RestaurantsRepository(); List <Restaurant> restaurants = repository.GetAll(); RestaurantsListViewModel model = new RestaurantsListViewModel(); model.Restaurants = restaurants; return(View(model)); }
public ActionResult Create() { UsersRepository rep = new UsersRepository(); ViewBag.UserId = new SelectList(rep.GetAll(), "Id", "Name"); RestaurantsRepository repo = new RestaurantsRepository(); ViewBag.RestaurantId = new SelectList(repo.GetAll(), "Id", "Name"); return(View()); }
public IActionResult AddRestaurant(Restaurants restaurants) { var added = new RestaurantsRepository().AddRestaurant(restaurants); if (added) { return(Json(new RestaurantsRepository().GetRestaurant(restaurants.ID))); } return(Json(null)); }
public static void AddDishToRestaurant(string restName, string dishName) { var restRepo = new RestaurantsRepository(); var rest = restRepo.FindBy(m => m.Name.StartsWith(restName)).FirstOrDefault(); var dishRepo = new SignatureDishesRepository(); var dish = dishRepo.FindBy(b => b.Name.StartsWith(dishName)).FirstOrDefault(); var context = new RestaurantContext(); context.Add(new RestaurantSignatureDish { SignatureDishId = dish.Id, RestaurantId = rest.Id }); context.SaveChanges(); }
// GET: Reservations public ActionResult Index() { ReservationsRepository repository = new ReservationsRepository(); ReservationsListViewModel model = new ReservationsListViewModel(); RestaurantsRepository rep = new RestaurantsRepository(); UsersRepository repo = new UsersRepository(); List <Reservation> reservations = repository.GetActive(); List <Restaurant> restaurants = rep.GetAll(); List <User> users = repo.GetAll(); model.Reservation = reservations; model.Restaurants = restaurants; model.Users = users; return(View(model)); }
public ActionResult Create(RestaurantCreateViewModel model) { if (!ModelState.IsValid) { return(View(model)); } Restaurant restaurant = new Restaurant(); restaurant.Name = model.Name; restaurant.Address = model.Address; restaurant.Email = model.Email; restaurant.OpenHour = model.OpenHour; restaurant.CloseHour = model.CloseHour; restaurant.Phone = model.Phone; restaurant.Capacity = model.Capacity; restaurant.ManagerId = model.ManagerId; RestaurantsRepository repository = new RestaurantsRepository(); repository.Insert(restaurant); return(RedirectToAction("Index")); }
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)); }
public ActionResult Edit(int Id) { ReservationsRepository repo = new ReservationsRepository(); Reservation dbreservation = new Reservation(); dbreservation = repo.Get(Id); ReservationsEditViewModel model = new ReservationsEditViewModel(); model.PeopleCount = dbreservation.PeopleCount; model.ReservationTime = dbreservation.ReservationTime; model.Comment = dbreservation.Comment; model.UserId = dbreservation.UserId; model.ResraurantId = dbreservation.RestaurantId; model.Id = Id; UsersRepository rep = new UsersRepository(); ViewBag.UserId = new SelectList(rep.GetAll(), "Id", "Name"); RestaurantsRepository repository = new RestaurantsRepository(); ViewBag.RestaurantId = new SelectList(repository.GetAll(), "Id", "Name"); return(View(model)); }
public ActionResult Create(ReservationsCreateViewModel model) { if (!ModelState.IsValid) { UsersRepository rep = new UsersRepository(); ViewBag.UserId = new SelectList(rep.GetAll(), "Id", "Name"); RestaurantsRepository repo = new RestaurantsRepository(); ViewBag.RestaurantId = new SelectList(repo.GetAll(), "Id", "Name"); return(View()); } else { Reservation reservation = new Reservation(); reservation.PeopleCount = model.PeopleCount; reservation.ReservationTime = model.ReservationTime; reservation.Comment = model.Comment; reservation.UserId = model.UserId; reservation.RestaurantId = model.ResraurantId; ReservationsRepository repository = new ReservationsRepository(); repository.Insert(reservation); return(RedirectToAction("Index")); } }
public ActionResult MostVisited() { MostVisitedCreateViewModel mostVisited = new MostVisitedCreateViewModel(); DateTime dateWeek = DateTime.Now.AddDays(-7); DateTime dateMonth = DateTime.Now.AddMonths(-1); DateTime dateYear = DateTime.Now.AddYears(-1); ReservationsRepository repository = new ReservationsRepository(); RestaurantsRepository rep = new RestaurantsRepository(); List <Restaurant> restaurants = rep.GetAll(); mostVisited.Restaurants = restaurants; UsersRepository repo = new UsersRepository(); List <User> users = repo.GetAll(); mostVisited.Users = users; //mostVisited.mostVisitedWeekly = repository.GetAll(n => n.ReservationTime > dateWeek && n.ReservationTime < DateTime.Now); mostVisited.mostVisitedWeekly = repository.GetAll(dateWeek); mostVisited.mostVisitedMonthly = repository.GetAll(dateMonth); mostVisited.mostVisitedYearly = repository.GetAll(dateYear); //mostVisited.mostVisitedMonthly = repository.GetAll(n => n.ReservationTime > dateMonth && n.ReservationTime < DateTime.Now); //mostVisited.mostVisitedYearly = repository.GetAll(n => n.ReservationTime > dateYear && n.ReservationTime < DateTime.Now); return(View(mostVisited)); }
public RestaurantsService(RestaurantsRepository repo) { _repo = repo; }
IList <Restaurant> IRepositoryOperation <IList <Restaurant>, RestaurantsRepository> .Execute(RestaurantsRepository p) { return((IList <Restaurant>)((ISqlLiteDbRepository)p).SelectAll()); }