public ActionResult NewRestaurant(NewRestaurant restaurantResponse)
        {
            if (ModelState.IsValid)
            {
                TempStorage.AddApplication(restaurantResponse);
                Response.Redirect("RestaurantList");
                //return View("RestaurantList",restaurantResponse);
            }


            return(View());
        }
Beispiel #2
0
 public IActionResult NewRestaurant(NewRestaurant restaurantResponse)
 {
     if (ModelState.IsValid)
     {
         TempStorage.AddRestaurant(restaurantResponse);
         Response.Redirect("RestaurantList");
         return(View(restaurantResponse));
     }
     else
     {
         return(View());
     }
 }
Beispiel #3
0
 public ActionResult NewRestaurant(string name, string address, string phone, HttpPostedFileBase img, string monStartTime, string monEndTime, string tueStartTime, string tueEndTime, string wedStartTime, string wedEndTime, string thuStartTime, string thuEndTime, string friStartTime, string friEndTime, string satStartTime, string satEndTime, string sunStartTime, string sunEndTime)
 {
     TempData["name"]    = name;
     TempData["address"] = address;
     TempData["phone"]   = phone;
     TempData["img"]     = img;
     if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(address) || string.IsNullOrEmpty(phone) || img == null && img.ContentLength == 0 || string.IsNullOrEmpty(monStartTime) || string.IsNullOrEmpty(monEndTime) || string.IsNullOrEmpty(tueStartTime) || string.IsNullOrEmpty(tueEndTime) || string.IsNullOrEmpty(wedStartTime) || string.IsNullOrEmpty(wedEndTime) || string.IsNullOrEmpty(thuStartTime) || string.IsNullOrEmpty(thuEndTime) || string.IsNullOrEmpty(friStartTime) || string.IsNullOrEmpty(friEndTime) || string.IsNullOrEmpty(satStartTime) || string.IsNullOrEmpty(satEndTime) || string.IsNullOrEmpty(sunStartTime) || string.IsNullOrEmpty(sunEndTime))
     {
         TempData["text"] = "上傳失敗,請檢查欄位資訊是否正確";
         return(View());
     }
     else
     {
         //存到資料夾
         var FileName = Path.GetFileName(img.FileName);
         var FilePath = Path.Combine(Server.MapPath("~/img/"), FileName);
         img.SaveAs(FilePath);
         //轉成byte 方法一 直接轉
         byte[] FileBytes;
         using (MemoryStream ms = new MemoryStream())
         {
             img.InputStream.CopyTo(ms);
             FileBytes = ms.GetBuffer();
         }
         var newStore = new NewRestaurant
         {
             MemberId          = Convert.ToInt32(Session["memberID"]),
             RestaurantName    = name,
             RestaurantAddress = address,
             RestaurantPhone   = phone,
             ImgBytes          = FileBytes,
             Mon    = monStartTime + " - " + monEndTime,
             Tue    = tueStartTime + " - " + tueEndTime,
             Wed    = wedStartTime + " - " + wedEndTime,
             Thu    = thuStartTime + " - " + thuEndTime,
             Fri    = friStartTime + " - " + friEndTime,
             Sat    = satStartTime + " - " + satEndTime,
             Sun    = sunStartTime + " - " + sunEndTime,
             Review = "review"
         };
         db.NewRestaurants.Add(newStore);
         db.SaveChanges();
         TempData["text"] = "上傳成功,審核時間1~3天";
         return(View());
     }
 }
Beispiel #4
0
 private void GetDataIntent()
 {
     newRestaurant = JsonConvert.DeserializeObject <NewRestaurant>(Intent.GetStringExtra("JSONRes"));
     password      = Intent.GetStringExtra("password");
 }