public ActionResult submitRestaurantApplicationData(RestaurantApplicationModel viewModel) { int result = 0; string constr = ConfigurationManager.ConnectionStrings["DeliviveConnection"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { string sql = "INSERT INTO End_User (Name,Phone,Password) VALUES ('" + viewModel.Name + "','" + viewModel.Phone + "','" + viewModel.Password + "');"; sql += "INSERT INTO Restaurant (Business_hour, Address, User_id) VALUES ('" + viewModel.Business_hour + "' , '" + viewModel.Address + "',(SELECT SCOPE_IDENTITY()));"; sql += "INSERT INTO Restaurant_Application (Restaurant_id, [Small_local], [Business_license], Short_answer, Restaurant_Decision)" + " VALUES ((SELECT SCOPE_IDENTITY()),'" + viewModel.Small_local + "','" + viewModel.Business_license + "','" + viewModel.Short_answer + "','false');"; using (SqlCommand cmd = new SqlCommand(sql)) { cmd.Connection = con; con.Open(); result = cmd.ExecuteNonQuery(); con.Close(); } if (result > 0) { return(Json("Successfully submitted the restaurant application!")); } else { return(Json("Error on submitting the restaurant application!")); } } }
// GET: Restaurant public ActionResult RestaurantApplication() { RestaurantApplicationModel viewModel = new RestaurantApplicationModel(); return(View(viewModel)); }