コード例 #1
0
 public ActionResult addRestaurant(restaurantViewModel formvalues)
 {
     if (TempData.ContainsKey("adminId"))
     {
         if (ModelState.IsValid)
         {
             try
             {
                 restaurantViewModel restaurantView = new restaurantViewModel();
                 ViewBag.status = restaurantView.listOfStatus;
                 restaurant restaurantTuple = formvalues.getRestaurantValues();
                 dbContext.restaurants.Add(restaurantTuple);
                 dbContext.SaveChanges();
                 return(RedirectToAction("index"));
             }
             catch (Exception ex)
             {
                 ViewBag.exception = ex.Message;
             }
             return(View());
         }
         else
         {
             return(View());
         }
     }
     else
     {
         TempData.Clear();
         return(RedirectToAction("LogIn", "LogIn"));
     }
 }
コード例 #2
0
ファイル: RestoController.cs プロジェクト: Lucillers/skiworld
 public ActionResult Delete(int id, restaurant rest)
 {
     rest = rss.GetById(id);
     rss.Delete(rest);
     rss.Commit();
     return(RedirectToAction("Index"));
 }
コード例 #3
0
    protected void ReadListFromDatabase(List <restaurant> list)
    {
        list.Clear();
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RestaurantsConnectionString"].ConnectionString);

        conn.Open();
        string testquery = "select * from Restaurants";

        SqlCommand com = new SqlCommand(testquery, conn);

        using (var command = com.ExecuteReader())
        {
            while (command.Read())
            {
                restaurant temp = new restaurant();
                temp.Id                         = command.GetInt32(0);
                temp.Place_Name                 = command.GetString(1);
                temp.Affectedfromweather        = command.GetBoolean(2);
                temp.Latest_Visit_Date          = command.GetDateTime(3);
                temp.Total_Visits_This_Month    = command.GetInt32(4);
                temp.CarorWalk                  = command.GetBoolean(5);
                temp.Total_People_Voted         = command.GetInt32(6);
                temp.Total_Votes                = command.GetInt32(7);
                temp.Average_Vote               = command.GetDouble(8);
                temp.Expected_Visits_This_Month = command.GetDouble(9);
                temp.Days_Since_Last_Visit      = command.GetInt32(10);
                list.Add(temp);
            }
        }
        conn.Close();
    }
コード例 #4
0
        public ActionResult Create(restaurant restaurant, HttpPostedFileBase[] tourism_photo)
        {
            string act_id = db.Database.SqlQuery <string>("Select dbo.GetrestId()").FirstOrDefault();

            restaurant.restaurant_id = act_id;
            restaurant.page_status   = false;

            string fileName = "";

            for (int i = 0; i < tourism_photo.Length; i++)
            {
                HttpPostedFileBase f = tourism_photo[i];
                if (f != null)
                {
                    if (f.ContentLength > 0)
                    {
                        string t = tourism_photo[i].FileName;
                        fileName = restaurant.restaurant_id + "_" + DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + (i + 1).ToString() + Path.GetExtension(t);
                        f.SaveAs(Server.MapPath("~/images/restaurant/" + fileName));
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_photo1 = fileName;
                        tp.tourism_id     = restaurant.restaurant_id;
                        db.tourism_photo.Add(tp);
                    }
                }
            }
            db.restaurant.Add(restaurant);
            db.SaveChanges();


            return(RedirectToAction("Index", new { page = Session["pg"] }));
        }
        public ActionResult ProductAdd(int id)
        {
            restaurant restaurant = models.restaurants.FirstOrDefault(x => x.restaurant_id == id);

            ViewBag.categories = models.categories.ToList();
            return(View(restaurant));
        }
コード例 #6
0
        public ActionResult Create(restaurant restaurant, HttpPostedFileBase tourism_photo)
        {
            string act_id = db.Database.SqlQuery <string>("Select dbo.GetrestId()").FirstOrDefault();

            restaurant.restaurant_id = act_id;

            string fileName = "";

            if (tourism_photo != null)
            {
                if (tourism_photo.ContentLength > 0)
                {
                    fileName = System.IO.Path.GetFileName(tourism_photo.FileName);
                    tourism_photo.SaveAs(Server.MapPath("~/images/restaurant/" + fileName));
                }
            }

            tourism_photo tp = new tourism_photo();

            tp.tourism_photo1 = fileName;
            tp.tourism_id     = restaurant.restaurant_id;

            db.restaurants.Add(restaurant);
            db.tourism_photo.Add(tp);
            db.SaveChanges();


            return(RedirectToAction("Index"));
        }
コード例 #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            restaurant restaurant = db.restaurants.Find(id);

            db.restaurants.Remove(restaurant);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #8
0
 public static Restaurant ToLibLayer(restaurant restaurantData)
 {
     List<Review> reviewsLib = new List<Review>();
     Restaurant restaurantLib = new Restaurant(restaurantData.name, restaurantData.address, restaurantData.phoneNumber, reviewsLib, restaurantData.id);
     foreach(review curRevData in restaurantData.reviews)
     {
         restaurantLib.reviews.Add(ReviewMapper.ToLibLayer(curRevData, restaurantLib));
     }
     return restaurantLib;
 }
コード例 #9
0
 public ActionResult Edit([Bind(Include = "restaurantId,name,location,contactnumber,Description")] restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
コード例 #10
0
 public ActionResult Edit([Bind(Include = "Restaurant_id,Restaurant_name,Restaurant_type,Restaurant_address,Restaurant_about,Restaurant_phone,OpenTime,closetime,image1")] restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
コード例 #11
0
        public ActionResult Index()
        {
            ViewBag.restaurants = models.restaurants.Where(x => x.username == User.Identity.Name).ToList();

            restaurant restaurant = models.restaurants.FirstOrDefault(x => x.username == User.Identity.Name);

            List <order_product> order_Products = models.order_product.Where(x => x.product.restaurant_id == restaurant.restaurant_id).ToList();

            return(View(order_Products));
        }
コード例 #12
0
        public ActionResult RestaurantDelete(int id)
        {
            restaurant      r  = models.restaurants.FirstOrDefault(x => x.restaurant_id == id);
            city_restaurant cr = models.city_restaurant.FirstOrDefault(x => x.restaurant_id == id);

            models.city_restaurant.Remove(cr);
            models.restaurants.Remove(r);
            models.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "restaurantId,name,location,contactnumber,Description")] restaurant restaurant)
        {
            if (ModelState.IsValid)
            {
                db.restaurants.Add(restaurant);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(restaurant));
        }
コード例 #14
0
 public RedirectResult Restaurant(int?id, restaurant i)
 {
     try {
         i.items_id = (int)id;
         restaurant.Update(i);
         Flash.Set(TempData, "Bam! Updated");
     } catch (Exception) {
         Flash.Set(TempData, "Sorry 😦");
     }
     return(Redirect("/Detail/?id=" + item.Get((int)id)));
 }
コード例 #15
0
 public ActionResult Edit([Bind(Include = "restaurant_id,restaurant_name,food_category_id,theme_area_id")] restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.theme_area_id = new SelectList(db.theme_areas, "theme_area_id", "theme_area_name", restaurant.theme_area_id);
     return(View(restaurant));
 }
コード例 #16
0
 protected void ShowRestaurant(restaurant r)
 {
     details.Visible = true;
     txtAddress.Text = r.location.address + ", "
                       + r.location.city + ", "
                       + r.location.province + " "
                       + r.location.postalCode;
     txtSummary.Text         = r.summary;
     drpRating.SelectedValue = r.rating.Value.ToString();
     lblConfirmation.Visible = false;
 }
コード例 #17
0
        public ActionResult Create([Bind(Include = "Restaurant_id,Restaurant_name,Restaurant_type,Restaurant_address,Restaurant_about,Restaurant_phone,OpenTime,closetime,image1")] restaurant restaurant)
        {
            if (ModelState.IsValid)
            {
                db.restaurants.Add(restaurant);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(restaurant));
        }
コード例 #18
0
 public ActionResult DelRes(string name)
 {
     using (quickmenumainEntities db = new quickmenumainEntities())
     {
         restaurant RestaurantDeletion = db.restaurant.Where(x => x.name == name).FirstOrDefault();
         db.restaurant.Remove(RestaurantDeletion);
         db.Database.ExecuteSqlCommand("DROP DATABASE `" + name + "`");
         db.SaveChanges();
         return(RedirectToAction("Index", "Control"));
     }
 }
コード例 #19
0
 public ActionResult Edit([Bind(Include = "restaurantID,restaurant_Name,restaurant_Address")] restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.restaurantID = new SelectList(db.Manager, "managerID", "manager_Name", restaurant.restaurantID);
     return(View(restaurant));
 }
コード例 #20
0
ファイル: RestoController.cs プロジェクト: Lucillers/skiworld
        public ActionResult Edit(int id, restaurant rest)
        {
            restaurant r = rss.GetById(id);

            r.closeDate = rest.closeDate;
            r.openDate  = rest.openDate;
            r.location  = rest.location;
            r.name      = rest.name;
            r.phone     = rest.phone;
            rss.Update(r);
            rss.Commit();
            return(RedirectToAction("Index"));
        }
コード例 #21
0
        private void start_work()
        {
            try
            {
                sushi = new restaurant();

                show_put_tables();
                generate_arrival();
                timer = new Timer(play, null, 0, 20000);
                show_host_message("Welcome to Taco Restaurant.");
            }
            catch (Exception exp) { }
        }
コード例 #22
0
        public static review ToDataLayer(Review reviewLib, restaurant restaurantData)
        {
            review reviewData = new review();

            reviewData.id           = reviewLib.id;
            reviewData.reviewerName = reviewLib.name;
            reviewData.comment      = reviewLib.comment;
            reviewData.rating       = (float)reviewLib.rating;
            reviewData.date         = reviewLib.dateTime;
            reviewData.restaurant   = restaurantData;

            return(reviewData);
        }
コード例 #23
0
        public ActionResult RestaurantUpdate(restaurant r)
        {
            restaurant restaurant = models.restaurants.FirstOrDefault(x => x.restaurant_id == r.restaurant_id);

            restaurant.restaurant_name    = r.restaurant_name;
            restaurant.username           = r.username;
            restaurant.restaurant_address = r.restaurant_address;
            restaurant.phone_number       = r.phone_number;


            models.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #24
0
        // GET: restaurants/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            restaurant restaurant = db.restaurants.Find(id);

            if (restaurant == null)
            {
                return(HttpNotFound());
            }
            return(View(restaurant));
        }
コード例 #25
0
        // GET: RestaurantAdmin/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            restaurant restaurant = db.restaurants.Find(id);

            if (restaurant == null)
            {
                return(HttpNotFound());
            }
            ViewBag.theme_area_id = new SelectList(db.theme_areas, "theme_area_id", "theme_area_name", restaurant.theme_area_id);
            return(View(restaurant));
        }
コード例 #26
0
ファイル: RestoController.cs プロジェクト: Lucillers/skiworld
        // GET: Resto/Edit/5
        public ActionResult Edit(int id)
        {
            restaurant rest = rss.GetById(id);
            restaurant rst  = new restaurant
            {
                closeDate  = rest.closeDate,
                openDate   = rest.openDate,
                location   = rest.location,
                name       = rest.name,
                phone      = rest.phone,
                starRating = rest.starRating
            };

            return(View(rest));
        }
コード例 #27
0
        public ActionResult LoginRestaurant(restaurant r)
        {
            var restaurants = models.restaurants.FirstOrDefault(x => x.username == r.username && x.restaurant_password == r.restaurant_password);

            if (restaurants != null)
            {
                FormsAuthentication.SetAuthCookie(restaurants.username, false);
                return(RedirectToAction("Index", "HomeUser"));
            }
            else
            {
                ViewBag.messageForRestaurant = "* We can't find that your account";
                return(RedirectToAction("Login"));
            }
        }
コード例 #28
0
        public static restaurant ToDataLayer(Restaurant restaurantLib)
        {
            restaurant restaurantData = new restaurant();
            restaurantData.id = restaurantLib.id;
            restaurantData.name = restaurantLib.name;
            restaurantData.address = restaurantLib.address;
            restaurantData.phoneNumber = restaurantLib.phoneNum;

            foreach (var curReviewLib in restaurantLib.reviews)
            {
                restaurantData.reviews.Add(ReviewMapper.ToDataLayer(curReviewLib, restaurantData));
            }

            return restaurantData;
        }
コード例 #29
0
        // GET: restaurants/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            restaurant restaurant = db.Restaurant.Find(id);

            if (restaurant == null)
            {
                return(HttpNotFound());
            }
            ViewBag.restaurantID = new SelectList(db.Manager, "managerID", "manager_Name", restaurant.restaurantID);
            return(View(restaurant));
        }
コード例 #30
0
        private List <restaurant> LoadRestaurants()
        {
            List <restaurant> restaurants = new List <restaurant>();

            using (quickmenumainEntities db = new quickmenumainEntities())
            {
                string email         = (string)Session["email"];
                var    GetRestaurant = db.restaurant.Where(x => x.user_email == email);
                foreach (var r in GetRestaurant)
                {
                    restaurant res = new restaurant();
                    res.name = r.name;
                    restaurants.Add(res);
                }
            }

            return(restaurants);
        }