public ActionResult RestaurantDetails(string idRest) { RestaurantBusinessLayer restBusinessLayer = new RestaurantBusinessLayer(); Restaurant restDetails = new Restaurant(); restDetails = restBusinessLayer.GetRestaurantDetails(idRest); return(View(restDetails)); }
public ActionResult Search(string AreaName, string CityName, string StateName, string CountryName) { AreaDetails areaDetails = areaBusinessLayer.AreaCoordinates(AreaName, CityName, StateName, CountryName); RestaurantBusinessLayer restBusinessLayer = new RestaurantBusinessLayer(); List <Restaurant> allrestaurants = restBusinessLayer.AllRestaurants(); List <Restaurant> closerestaurants = new List <Restaurant>(); foreach (var rest in allrestaurants) { double distanceinkms = Distance.Calculate(Convert.ToDouble(areaDetails.Latitude), Convert.ToDouble(areaDetails.Longitude), Convert.ToDouble(rest.Latitude), Convert.ToDouble(rest.Longitude)); if (distanceinkms <= 5) { closerestaurants.Add(rest); } } return(View(closerestaurants)); }
public ActionResult AddRestaurant(Restaurant model) { if (Session["UserDisplayName"] != null) { //model.HomeDelivery = Convert.ToBoolean(model.HomeDelivery); if (ModelState.IsValid) { //try //{ RestaurantBusinessLayer restaurantBusinessLayer = new RestaurantBusinessLayer(); Restaurant restaurant = new Restaurant(); int restId = restaurantBusinessLayer.AddRestaurant(model); return(RedirectToAction("AddRestaurantImages", "Home", new { idRest = restId })); //} //catch (MembershipCreateUserException e) //{ // ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); //} } // If we got this far, something failed, redisplay form List <Country> lstCountries = countryBusinessLayer.GetCountryList(); ViewBag.Countries = new SelectList(lstCountries, "CountryId", "CountryName"); IEnumerable <HomeDelivery> HomeDeliveryTypes = Enum.GetValues(typeof(HomeDelivery)) .Cast <HomeDelivery>(); model.HomeDeliveryList = from homedelivery in HomeDeliveryTypes select new SelectListItem { Text = homedelivery.ToString(), Value = ((int)homedelivery).ToString() }; return(View(model)); } else { return(RedirectToAction("Login", "Account")); } }
public ActionResult AddRestaurantImages(HttpPostedFileBase MainImagePath, int RestId, HttpPostedFileBase CoverImageFile, HttpPostedFileBase Image1, HttpPostedFileBase Image2, HttpPostedFileBase Image3, HttpPostedFileBase Image4, HttpPostedFileBase Image5, HttpPostedFileBase Image6) { if (MainImagePath != null && MainImagePath.ContentLength > 0) { try { string path = Path.Combine(Server.MapPath("~/Content/files"), Path.GetFileName(MainImagePath.FileName)); MainImagePath.SaveAs(path); string coverimagepath = Path.Combine(Server.MapPath("~/Content/files"), Path.GetFileName(CoverImageFile.FileName)); CoverImageFile.SaveAs(coverimagepath); string image1path = Path.Combine(Server.MapPath("~/Content/files"), Path.GetFileName(Image1.FileName)); Image1.SaveAs(image1path); string image2path = Path.Combine(Server.MapPath("~/Content/files"), Path.GetFileName(Image2.FileName)); Image2.SaveAs(image2path); string image3path = Path.Combine(Server.MapPath("~/Content/files"), Path.GetFileName(Image3.FileName)); Image3.SaveAs(image3path); string image4path = Path.Combine(Server.MapPath("~/Content/files"), Path.GetFileName(Image4.FileName)); Image4.SaveAs(image4path); string image5path = Path.Combine(Server.MapPath("~/Content/files"), Path.GetFileName(Image5.FileName)); Image5.SaveAs(image5path); string image6path = Path.Combine(Server.MapPath("~/Content/files"), Path.GetFileName(Image6.FileName)); Image6.SaveAs(image6path); RestaurantBusinessLayer restaurantBusinessLayer = new RestaurantBusinessLayer(); Restaurant model = new Restaurant(); model.RestId = RestId; model.MainImagePath = Path.GetFileName(MainImagePath.FileName); model.CoverImagePath = Path.GetFileName(CoverImageFile.FileName); model.Image1 = Path.GetFileName(Image1.FileName); model.Image2 = Path.GetFileName(Image2.FileName); model.Image3 = Path.GetFileName(Image3.FileName); model.Image4 = Path.GetFileName(Image4.FileName); model.Image5 = Path.GetFileName(Image5.FileName); model.Image6 = Path.GetFileName(Image6.FileName); restaurantBusinessLayer.AddRestaurantImages(model); return(RedirectToAction("RestaurantDetails", "Home", new { idRest = RestId })); } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { ViewBag.Message = "You have not specified a file."; } //return View(); return(RedirectToAction("RestaurantDetails", "Home", new { idRest = RestId })); }