public ActionResult CreateRestaurant()
 {
     var universities = db.Universities.Select(i => new { Text = i.UniversityName, Value = i.UniversityId }).ToList()
                                       .Select(i => new SelectListItem() { Text = i.Text, Value = i.Value.ToString() });
     ViewData["Universities"] = universities.ToList();
     ViewData["NewRestaurant"] = "1";
     var restaurant = new Restaurant();
     return View("ManageRestaurantDetails", restaurant);
 }
        public ActionResult CreateRestaurant(FormCollection values)
        {
            var location = new Location() {
                LocationName = values["Location_LocationName"],
                BusinessName = values["Location_LocationName"],
                Address1 = values["Location_Address1"],
                Address2 = values["Location_Address2"],
                City = values["Location_City"],
                StateOrProvince = values["Location_StateOrProvince"],
                ZipCode = values["Location_ZipCode"],
                FirstName = "",
                LastName = "",
                Country = "United States",
                 CountryCode= CountryCodeType.US.ToString()
            };
            db.Locations.AddObject(location);
            DateTime? hoursFrom=null, hoursTo=null, hours2From=null, hours2To=null;
            if(!string.IsNullOrEmpty(values["RestaurantHoursFrom"])) {
                hoursFrom = DateTime.Parse(values["RestaurantHoursFrom"]);
            }
            if(!string.IsNullOrEmpty(values["RestaurantHoursTo"])) {
                hoursTo = DateTime.Parse(values["RestaurantHoursTo"]);
            }
            if(!string.IsNullOrEmpty(values["RestaurantHours2From"])) {
                hours2From = DateTime.Parse(values["RestaurantHours2From"]);
            }
            if(!string.IsNullOrEmpty(values["RestaurantHours2To"])) {
                hours2To = DateTime.Parse(values["RestaurantHours2To"]);
            }
            var restaurant = new Restaurant()
            {
                RestaurantName = values["RestaurantName"],
                RestaurantShortDescription = values["RestaurantShortDescription"],
                RestaurantDetailedDescription = values["RestaurantDetailedDescription"],
                RestaurantHoursFrom = hoursFrom,
                RestaurantHoursTo = hoursTo,
                RestaurantHours2From = hours2From,
                RestaurantHours2To = hours2To,
                UniversityId = int.Parse(values["UniversityId"]),
                RestaurantStatusId = (int)Enum.Parse(typeof(RestaurantStatusLevel), values["RestaurantStatus"]),
                Location = location,
                RestaurantImageUrl = "",
            };
            db.Restaurants.AddObject(restaurant);

            var bowl = new BentoBox()
            {
                BentoBoxName = "1-Entree Plate",
                BentoBoxDescription = "1-Entree Plate",
                BentoBoxTypeId = (int)BentoBoxType.OneEntreePlate,
                BentoBoxStatusId = (int)BentoBoxStatusLevel.Unavailable,
                Restaurant = restaurant,
                BentoBoxImageUrl = "",
                UnitPrice = 5.99m
            };
            var twoEntree = new BentoBox()
            {
                BentoBoxName = "2-Entree Plate",
                BentoBoxDescription = "2-Entree Plate",
                BentoBoxTypeId = (int)BentoBoxType.TwoEntreePlate,
                BentoBoxStatusId = (int)BentoBoxStatusLevel.Unavailable,
                Restaurant = restaurant,
                BentoBoxImageUrl = "",
                UnitPrice = 6.99m
            };
            var threeEntree = new BentoBox()
            {
                BentoBoxName = "3-Entree Plate",
                BentoBoxDescription = "3-Entree Plate",
                BentoBoxTypeId = (int)BentoBoxType.ThreeEntreePlate,
                BentoBoxStatusId = (int)BentoBoxStatusLevel.Unavailable,
                Restaurant = restaurant,
                BentoBoxImageUrl = "",
                UnitPrice = 7.99m
            };
            var noodleAndRice = new BentoBox()
            {
                BentoBoxName = "Noodle and Rice",
                BentoBoxDescription = "Noodle and Rice",
                BentoBoxTypeId = (int)BentoBoxType.NoodleAndRice,
                BentoBoxStatusId = (int)BentoBoxStatusLevel.Unavailable,
                Restaurant = restaurant,
                BentoBoxImageUrl = "",
                UnitPrice = 6.99m
            };
            db.BentoBoxes.AddObject(bowl);
            db.BentoBoxes.AddObject(twoEntree);
            db.BentoBoxes.AddObject(threeEntree);
            db.BentoBoxes.AddObject(noodleAndRice);
            db.SaveChanges();
            return RedirectToAction("ManageRestaurants");
        }
Beispiel #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Restaurants EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRestaurants(Restaurant restaurant)
 {
     base.AddObject("Restaurants", restaurant);
 }
Beispiel #4
0
 /// <summary>
 /// Create a new Restaurant object.
 /// </summary>
 /// <param name="restaurantId">Initial value of the RestaurantId property.</param>
 /// <param name="restaurantName">Initial value of the RestaurantName property.</param>
 /// <param name="restaurantStatusId">Initial value of the RestaurantStatusId property.</param>
 /// <param name="restaurantLocationId">Initial value of the RestaurantLocationId property.</param>
 /// <param name="universityId">Initial value of the UniversityId property.</param>
 public static Restaurant CreateRestaurant(global::System.Int32 restaurantId, global::System.String restaurantName, global::System.Int32 restaurantStatusId, global::System.Int32 restaurantLocationId, global::System.Int32 universityId)
 {
     Restaurant restaurant = new Restaurant();
     restaurant.RestaurantId = restaurantId;
     restaurant.RestaurantName = restaurantName;
     restaurant.RestaurantStatusId = restaurantStatusId;
     restaurant.RestaurantLocationId = restaurantLocationId;
     restaurant.UniversityId = universityId;
     return restaurant;
 }