예제 #1
0
        public ActionResult Create(spot spot, HttpPostedFileBase[] tourism_photo)
        {
            //表單內容
            string act_id = db.Database.SqlQuery <string>("Select dbo.GetspotId()").FirstOrDefault();

            spot.spot_id     = act_id;
            spot.update_date = DateTime.Now;
            spot.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 = spot.spot_id + "_" + DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + (i + 1).ToString() + Path.GetExtension(t);
                        f.SaveAs(Server.MapPath("~/images/spot/" + fileName));
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_photo1 = fileName;
                        tp.tourism_id     = spot.spot_id;
                        db.tourism_photo.Add(tp);
                    }
                }
            }
            db.spot.Add(spot);
            db.SaveChanges();


            return(RedirectToAction("Index", new { page = Session["pg"] }));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "admin_id,admin_account,admin_password,admin_email,emailConfirmed")] admin admin)
        {
            if (ModelState.IsValid)
            {
                byte[] password     = System.Text.Encoding.UTF8.GetBytes(admin.admin_password);
                byte[] hash         = new System.Security.Cryptography.SHA256Managed().ComputeHash(password);
                string hashpassword = Convert.ToBase64String(hash);
                admin.admin_password = hashpassword;
                admin.emailConfirmed = false;


                var         callbackUrl = Url.Action("Confirm", "Admin", new { account = admin.admin_account }, protocol: Request.Url.Scheme);
                GmailSender gs          = new GmailSender();
                gs.account     = "*****@*****.**";
                gs.password    = "******";
                gs.sender      = "旅途貓 <*****@*****.**>";
                gs.receiver    = $"{admin.admin_email}";
                gs.subject     = "旅途貓驗證";
                gs.messageBody = "恭喜註冊成功<br><a href=" + callbackUrl + ">請點此連結</a>";
                gs.IsHtml      = true;
                gs.Send();

                db.admin.Add(admin);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(admin));
        }
예제 #3
0
        public IHttpActionResult Putmessage(long id, message message)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != message.msg_id)
            {
                return(BadRequest());
            }

            db.Entry(message).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!messageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #4
0
        public ActionResult Create(hotel hotel, HttpPostedFileBase tourism_photo)
        {
            string h_id = db.Database.SqlQuery <string>("Select dbo.GethotelId()").FirstOrDefault();

            hotel.hotel_id = h_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/hotel/" + fileName));
                }
            }

            tourism_photo tp = new tourism_photo();

            tp.tourism_photo1 = fileName;
            tp.tourism_id     = hotel.hotel_id;

            db.hotels.Add(hotel);
            db.tourism_photo.Add(tp);
            db.SaveChanges();


            return(RedirectToAction("Index"));
        }
        public IHttpActionResult Putcomment_emoji_details(long id, comment_emoji_details comment_emoji_details)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != comment_emoji_details.id)
            {
                return(BadRequest());
            }

            db.Entry(comment_emoji_details).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!comment_emoji_detailsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #6
0
        public ActionResult Create([Bind(Include = "msg_id,msg_time,msg_content,comment_id,member_id")] message message)
        {
            if (ModelState.IsValid)
            {
                db.message.Add(message);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.comment_id = new SelectList(db.comment, "comment_id", "tourism_id", message.comment_id);
            ViewBag.member_id  = new SelectList(db.member, "member_id", "member_account", message.member_id);
            return(View(message));
        }
예제 #7
0
        public ActionResult Index(member model, HttpPostedFileBase photo)
        {
            string mem_id = db.Database.SqlQuery <string>("Select dbo.GetmemberId()").FirstOrDefault();

            model.member_id = mem_id;
            model.member_profile.member_id      = mem_id;
            model.member_profile.member_score   = 0;
            model.member_profile.create_time    = DateTime.Now;
            model.member_profile.emailConfirmed = false;

            byte[] password     = System.Text.Encoding.UTF8.GetBytes(model.member_password);
            byte[] hash         = new System.Security.Cryptography.SHA256Managed().ComputeHash(password);
            string hashpassword = Convert.ToBase64String(hash);

            model.member_password = hashpassword;

            string fileName = "";

            if (photo != null)
            {
                if (photo.ContentLength > 0)
                {
                    string t = photo.FileName;
                    fileName = mem_id + "_" + DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + Path.GetExtension(t);
                    photo.SaveAs(Server.MapPath("~/images/member/" + fileName));
                    model.member_profile.profile_photo = fileName;
                }
            }

            var callbackUrl = Url.Action("Confirm", "Register", new { account = model.member_account, id = mem_id }, protocol: Request.Url.Scheme);

            if (ModelState.IsValid)
            {
                GmailSender gs = new GmailSender();
                gs.account     = "*****@*****.**";
                gs.password    = "******";
                gs.sender      = "旅途貓 <*****@*****.**>";
                gs.receiver    = $"{model.member_profile.email}";
                gs.subject     = "旅途貓驗證";
                gs.messageBody = "恭喜註冊成功<br><a href=" + callbackUrl + ">請點此連結</a>";
                gs.IsHtml      = true;
                gs.Send();


                db.member.Add(model);
                db.member_profile.Add(model.member_profile);
                db.SaveChanges();
                return(RedirectToAction("ConfirmView", "Register", new { account = model.member_account }));
            }
            return(View(model));
        }
예제 #8
0
        public IHttpActionResult Post(string memberId, string issueContent, int issue_id, string problem_id = null)
        {
            issue issue = new issue();

            issue.member_id     = memberId;
            issue.issue_content = issueContent;
            issue.admin_id      = 1;
            issue.issue_id      = issue_id;
            issue.report_date   = DateTime.Now;
            issue.problem_id    = problem_id;
            db.issue.Add(issue);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = issue.id }, issue));
        }
예제 #9
0
        public ActionResult Edit([Bind(Include = "member_id,member_account,member_password,member_status")] member member)
        {
            string email = db.member_profile.Where(m => m.member_id == member.member_id).FirstOrDefault().email;

            if (member.member_status == true)
            {
                GmailSender gs = new GmailSender();
                gs.account     = "*****@*****.**";
                gs.password    = "******";
                gs.sender      = "旅途貓 <*****@*****.**>";
                gs.receiver    = $"{email}";
                gs.subject     = "會員通知";
                gs.messageBody = "<h3>親愛的會員您好:</h3><br /><p>因您已違反本網站規定,本站將取消您的會員,如有任何疑問請與本站客服人員聯絡。</p>";
                gs.IsHtml      = true;
                gs.Send();
            }

            if (ModelState.IsValid)
            {
                db.Entry(member).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(member));
        }
예제 #10
0
        public ActionResult Index(string id, HttpPostedFileBase photo)
        {
            member member = db.member.Find(id);

            string fileName = "";

            if (photo != null)
            {
                if (photo.ContentLength > 0)
                {
                    string t = photo.FileName;
                    fileName = member.member_profile.member_id + "_" + DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + Path.GetExtension(t);
                    if (member.member_profile.profile_photo != null)
                    {
                        System.IO.File.Delete(Server.MapPath("~/images/member/" + member.member_profile.profile_photo));
                    }
                    photo.SaveAs(Server.MapPath("~/images/member/" + fileName));
                    member.member_profile.profile_photo = fileName;
                }
            }
            if (ModelState.IsValid)
            {
                db.Entry(member.member_profile).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "web_Member_Index", new { id = member.member_id }));
            }

            return(View(member));
        }
예제 #11
0
        public ActionResult Postcollections_detail(string member_id, string tourism_id, int collection_type_id = 1)
        {
            string id = tourism_id.Substring(0, 1);
            string controller;

            switch (id)
            {
            case "A":
                controller = "web_activities";
                break;

            case "H":
                controller = "WebHotels";
                break;

            case "R":
                controller = "WebRestaurants";
                break;

            case "S":
                controller = "WebSpots";
                break;

            default:
                controller = "web_activities";
                break;
            }
            collections_detail collect = new collections_detail()
            {
                member_id          = member_id,
                tourism_id         = tourism_id,
                privacy            = true,
                collection_type_id = collection_type_id
            };


            if (ModelState.IsValid)
            {
                db.collections_detail.Add(collect);
                db.SaveChanges();
                return(RedirectToRoute(new { controller = controller, action = "Details", id = tourism_id }));
            }

            return(RedirectToRoute(new { controller = controller, action = "Details", id = tourism_id }));
        }
예제 #12
0
        [HttpPost]                                                                        //預設就是httpget,這裡是要讓他新增資料到資料庫
        public ActionResult Create(activity activity, HttpPostedFileBase[] tourism_photo) //多載(overloading/overloading)
        {
            string act_id = db.Database.SqlQuery <string>("Select dbo.GetactivityId()").FirstOrDefault();

            activity.activity_id = act_id;
            activity.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 = activity.activity_id + "_" + DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + (i + 1).ToString() + Path.GetExtension(t);
                        f.SaveAs(Server.MapPath("~/images/activity/" + fileName));
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_photo1 = fileName;
                        tp.tourism_id     = activity.activity_id;
                        db.tourism_photo.Add(tp);
                    }
                }
            }
            db.activity.Add(activity);
            db.SaveChanges();
            //try
            //{
            //    db.SaveChanges();
            // }
            //catch (DbEntityValidationException ex)
            //{
            //  var entityError = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
            //var getFullMessage = string.Join("; ", entityError);
            //var exceptionMessage = string.Concat(ex.Message, "errors are: ", getFullMessage);
            //NLog
            //return View(exceptionMessage.ToString());

            //}

            return(RedirectToAction("Index", new { page = Session["pg"] }));
        }
예제 #13
0
        public ActionResult Edit([Bind(Include = "id,member_id,admin_id,issue_id,report_date,issue_content,issue_result,issue_status,resolve_date,problem_id")] issue issue)
        {
            string email   = db.member_profile.Where(m => m.member_id == issue.member_id).FirstOrDefault().email;
            string result  = issue.issue_result;
            string content = issue.issue_content;

            int    id = issue.issue_id;
            string controller;

            switch (id)
            {
            case 1:
                controller = "issues";
                break;

            case 2:
                controller = "members";
                break;

            case 3:
                controller = "comments";
                break;

            case 4:
                controller = "messages";
                break;

            default:
                controller = "issues";
                break;
            }

            if (issue.issue_status == true)
            {
                GmailSender gs = new GmailSender();
                gs.account     = "*****@*****.**";
                gs.password    = "******";
                gs.sender      = "旅途貓 <*****@*****.**>";
                gs.receiver    = $"{email}";
                gs.subject     = "系統問題回覆";
                gs.messageBody = "<div><h3>關於您的問題:</h3><p>" + content + "</p><br></div>" + "<div><h3>以下是本網站針對此問題做出的回覆:</h3><p>" + result + "</p></div><br><footer>感謝您寶貴的建議,全體人員在此感謝。</footer>";
                gs.IsHtml      = true;
                gs.Send();
            }
            issue.resolve_date = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Entry(issue).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToRoute(new { controller = controller, action = "Index", tab = 2 }));
            }

            ViewBag.admin_id = new SelectList(db.admin, "admin_id", "admin_account", issue.admin_id);

            return(View(issue));
        }
예제 #14
0
        // GET: ImportTEST
        public void LoadJson()
        {
            using (StreamReader r = new StreamReader(@"D:\TravelCAT\TravelCat\spot_C_f.json"))
            {
                var json             = r.ReadToEnd();
                List <Rootobject> rt = JsonConvert.DeserializeObject <List <Rootobject> >(json);

                for (int i = 0; i < rt.Count; i++)
                {
                    spot items = new spot();
                    items.spot_id         = db.Database.SqlQuery <string>("Select dbo.GetspotId()").FirstOrDefault();
                    items.spot_intro      = rt[i].Toldescribe;
                    items.spot_tel        = rt[i].Tel;
                    items.spot_title      = rt[i].Name;
                    items.latitude        = rt[i].Py.ToString();
                    items.longitude       = rt[i].Px.ToString();
                    items.addition_note   = rt[i].Remarks;
                    items.address_detail  = rt[i].Add;
                    items.city            = rt[i].Region;
                    items.district        = rt[i].Town;
                    items.open_time       = rt[i].Opentime;
                    items.ticket_info     = rt[i].Ticketinfo;
                    items.update_date     = rt[i].Changetime;
                    items.travelling_info = rt[i].Travellinginfo;


                    if (String.IsNullOrEmpty(rt[i].Picture1) != true)
                    {
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_id     = items.spot_id;
                        tp.tourism_photo1 = rt[i].Picture1;
                        db.tourism_photo.Add(tp);
                    }
                    if (String.IsNullOrEmpty(rt[i].Picture2) != true)
                    {
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_id     = items.spot_id;
                        tp.tourism_photo1 = rt[i].Picture2;
                        db.tourism_photo.Add(tp);
                    }
                    if (String.IsNullOrEmpty(rt[i].Picture3) != true)
                    {
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_id     = items.spot_id;
                        tp.tourism_photo1 = rt[i].Picture3;
                        db.tourism_photo.Add(tp);
                    }

                    db.spot.Add(items);

                    db.SaveChanges();
                }

                Console.WriteLine("success");
            }
        }
예제 #15
0
        public ActionResult Edit(comment comment)
        {
            if (ModelState.IsValid)
            {
                db.Entry(comment).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(comment));
        }
예제 #16
0
        //水軍遊樂場
        public ActionResult generate_comment()
        {
            List <comment> comments = db.comment.Where(s => s.tourism_id.Contains("H")).Take(1260).OrderBy(m => Guid.NewGuid()).ToList();

            //string id = "";
            string[] title = { "大說謊家",  "下禮拜要報告好緊張",                                  "錢多事少離家近 數錢數到手抽筋", "熱氣球飛行家",
                               "去年聖誕節", "Google goes offline after fibre cables cut", "布魯克林孤兒",          "遲到騎車還下雨 有夠難過","Robert Downey Jr launches YouTube doc featuring AI","Airbnb is not an estate agent, EU court rules", "Inside the lives of Orthodox Jewish women", "Why did an entire civilisation vanish?", "鋒迴路轉", "賽道狂人", "82年生的金智英" };
            string[] content = { "Crews are battling over 100 fires amid a heatwave which has produced the nation's two hottest days on record.<br>Two volunteer firefighters died in a road accident on Thursday while deployed to a huge blaze near Sydney.<br>Mr Morrison said he would end his leave early.His absence this week has drawn condemnation and protests.",
                                 "德國時間周一(12月10日)晚上時份,一家生產巧克力的工廠,因巧克力罐洩漏,導致大量液態巧克力流出,覆蓋了大約10平方米(108平方英尺)的地面,令西部城鎮韋爾市的一條道路封閉。<br>由於巧克力迅速在地面凝固,25名消防員需要使用鐵鏟,熱水和噴槍清理現場,巧克力工廠的員工亦有協助清理。<br>當地消防部門說:「儘管發生了如此讓人沮喪的事情,這個聖誕節還是不能沒有巧克力。」<br>此家工廠之前保證,他們的工廠於周三恢復正常運營。",
                                 "多方分析指出,近年來大量歐盟和非歐盟移民湧入,是造成英國民間脫歐情緒高漲的主要原因之一。移民改革的第一步就是脫歐第一日起終止歐盟國家居民自由在英國居住與工作的權利。<br>約翰遜在競選期間就多次承諾,希望在英國實行澳大利亞式的移民打分制度,也就是說依照移民申請人的實力、能力等各類條件打分,然後按年度指標有秩序地吸收夠條件的人士移民。<br>新移民法提案還專門提出加快對英國老齡化社會所迫切需要的醫生、護士等醫療服務人員的簽證處理時間。",
                                 "除上述一些主要施政要點外,英國政府也希望能在新議會期間通過有關環保和氣候變化,社會養老,選舉制度改革等許多方面的新法。<br>觀察人士指出,由於執政保守黨目前在英國議會中佔有80席多數,因此可以基本確保通過任何立法提案。約翰遜首相政府也可以說是擁有自1987年撒切爾(戴卓爾)夫人首相政府以來的最強勢保守黨政府。<br>對英國政府來說,未來國內政治最大不確定因素應是由蘇格蘭民族黨不斷希望推動的獨立公投,而國際上則有脫歐之後與歐盟關係,以及如何在美中對抗加劇的今日,擺好英國立場的抉擇。",
                                 "Temperatures have exceeded 45C in several states this week, fanning bushfires in South Australia and NSW.<br>On Thursday, NSW Premier Gladys Berejiklian announced a seven-day state of emergency due to forecasts of worsening conditions. The intense heat is expected to persist into Saturday, forecasters warn.<br>The nation may have its all-time temperature record broken again after it was smashed twice this week. It hit a high of 41.9C (107.4F) on Wednesday.<br>Of the firefighters' deaths, the NSW Rural Fire Service said: 'This is an absolutely devastating event in what has already been an incredibly difficult day and fire season.'<br>",
                                 "教育部國民及學前教育署今天組成專案小組到長榮中學瞭解狀況,晚間得出初步結論。國教署告訴媒體,校方表示將從2個途徑籌措財源,包括持續與銀行接洽借款;另外,基督教長老總會預計於25日派人到校,校方會努力向其爭取資金挹注。<br>長榮中學於今年8月傳出未與教師協議即刪減學術研究費,引起教師抗爭,教育部也3度發文要求改善。教育部表示,校方於明天下午3時與工會代表進行團體協議,將關注後續結果。<br>教育部表示,期望長榮中學的董事會、行政團隊與教師作理性溝通,啟動協商,共同面對學生減少的情勢,規劃學校轉型,共謀校務創新發展途徑。",
                                 "故事主角是一個不曾相信過任何人的職業騙徒:羅伊寇特尼(伊恩麥克連 飾),他一生中無所不騙,心狠手辣毫不留情,而且不留下任何痕跡。某日他在網路上認識一名有錢的寡婦:貝蒂麥雷許(海倫米蘭 飾)。兩人見面後相談甚歡,毫無疑問地,貝蒂很快就被羅伊幽默風趣的談吐與溫柔貼心的態度所吸引,但出乎羅伊意料的是貝蒂竟是他這一生中見過最聰明、優雅、風趣而且有品味的女性;貝蒂對羅伊敞開心胸毫不隱瞞,大方地打開大門邀請他進入她家與她的人生中,此時的羅伊開始驚訝地發現自己竟然是真心喜歡貝蒂,他一生中未曾有過如此心動的感覺,讓原本按照計畫應該發生的騙局,竟在最後的轉瞬間峰迴路轉,面對這個一生一次能讓自己動心的女人,羅伊將會做出什麼樣的選擇?",
                                 "真人實事改編,19世紀科學家詹姆斯葛萊舍(艾迪瑞德曼 飾)與熱氣球駕駛員艾蜜莉雷恩(費莉絲蒂瓊斯 飾)挑戰「飛」出人類極限高度。為了實驗熱氣球可飛行高度,科學家詹姆斯帶著飛行員艾蜜莉一同實驗,而在飛行途中發生一連串的狀況與事件,隨著高度越高,空氣越來越稀薄,兩人該如何面對接下來的挑戰?",
                                 "五歲的星星(陳品嫙 飾)有個跟別人不一樣的媽媽小青(姚愛寗 飾),愛笑的小青最喜歡跟星星一起玩耍,相依為命的兩人總在一聲聲的「謝謝」與「對不起」中尋求大家的認同與諒解。小青為了生活,帶著星星到市場打工,卻無意惹禍上身,開啟了一連串的麻煩事,甚至丟了工作,還引起新聞媒體的注意,爆出小青不堪的過往……。<br>在社會輿論的壓力下,社會局決定安排星星到寄養家庭,然而這個表面上《最好的安排》,竟成了小青母女倆《最壞的決定》。面對現實的壓迫與社會的歧視,小青決心帶著星星離開,但他們究竟該何去何從呢?<br>今年冬天最動人的溫馨電影《為你存在的每一天》,由資深監製曾禎執導,新生代演員群姚愛寗、黃遠、于樂誠及天才童星陳品嫙主演,本片大膽碰觸國片少見的社會弱勢議題,以及主演演技加持,近日已榮獲洛杉磯菲斯蒂喬斯國際影展六項大獎、義大利奧尼羅電影獎最佳劇情片、倫敦獨立電影獎兩項大獎以及入圍美國獨立電影獎最佳亞洲劇情片。《為你存在的每一天》將於12月13日全台閃耀上映,更多電影資訊請上官方粉絲團查詢。",
                                 "一事無成的凱特(艾蜜莉亞克拉克 飾)在倫敦渾渾噩噩地過日子,她做出一連串的糟糕決定導致的厄運總是伴隨著鞋子上發出的鈴聲如影隨形地跟著她,因為她只能打扮成聖誕老公公的小精靈,在一間全年無休的聖誕飾品店當店員。於是當心地善良的大帥哥湯姆(亨利高汀 飾)闖入凱特的人生,並且開始幫助她克服她人生中的許多障礙與難關,這一切都似乎美好得有點不真實。當倫敦在聖誕佳節期間轉變成一座童話般的夢幻王國,這兩個看似八竿子打不著的人應該不會結成良緣,但有時候你得順其自然、聆聽內心的聲音…而且一定要擁有信念。<br>《去年聖誕節》一片中有許多喬治麥可的經典名曲,當然包括與電影同名,詞意苦中帶甜的經典聖誕歌曲。這部電影中也有一些這位曾經榮獲多項葛萊美獎的傳奇歌手從未發表過的全新歌曲。喬治麥可在輝煌的演藝生涯中,總共賣出1億1千5百萬張專輯,並且擁有10首冠軍單曲。",
                                 "萊諾艾斯洛(艾德華諾頓 飾),一名患有妥瑞症的孤獨私家偵探,他的良師和唯一朋友法蘭克敏納(布魯斯威利 飾)遭到謀殺,他冒著生命危險設法破案。他手上只有寥寥無幾的線索,不過他滿懷衝勁,解開了層層掩飾的重大祕密,而那攸關著能否讓紐約市維持和諧的命運。在一連串的神祕事件中,他從哈林區醉生夢死的爵士俱樂部,來到布魯克林區邊緣化的貧民窟,最後來到紐約權力經紀人的陣地,萊諾必須對付流氓、腐敗和全市最危險的人,為的只是向他的朋友致敬,並拯救可能會讓他獲得救贖的女人。" };
            string[] date  = { "2019-08-07", "2019-01-05", "2016-05-20", "2019-12-13", "2018-08-23", "2019-12-20", "2019-09-26" };
            string[] photo = { "01_ash.png", "02_candy_crush.jpg", "03_goodboy.jpg", "G4wXXRk.gif", "12_goodguy.png", "01_sleep.jpg", "01_sleeves.jpg", "05_gaming.jpg", "05_report.jpg", "06_gf_zero.jpg", "10_crow.jpg", "11_math.jpg", "11_spiderman.jpg", "13_ad.jpg", "16_useful.jpg", "19_hell.jpg", "20_bean.jpg" };
            //string[] memberID = { "M000001", "M000002", "M000003", "M000004", "M000005" };
            string[] partner = { "蜜月", "伴侶", "朋友", "商務", "家庭" };

            Random random = new Random();

            for (int i = 0; i < 400; i++)
            {
                comment  cmt        = new comment();
                DateTime parsedDate = DateTime.Parse(date[random.Next(0, 7)]);

                cmt.tourism_id         = comments[i].tourism_id;
                cmt.comment_title      = title[random.Next(0, 15)];
                cmt.comment_content    = content[random.Next(0, 11)];
                cmt.comment_date       = parsedDate;
                cmt.comment_photo      = photo[random.Next(0, 17)];
                cmt.comment_stay_total = random.Next(1, 5);
                cmt.comment_rating     = Convert.ToInt16(random.Next(3, 6));
                cmt.travel_month       = random.Next(1, 13).ToString();
                cmt.comment_status     = true;
                cmt.member_id          = db.member.ToList()[random.Next(0, 30)].member_id;
                cmt.travel_partner     = partner[random.Next(0, 5)];

                if (ModelState.IsValid)
                {
                    db.comment.Add(cmt);
                    db.SaveChanges();
                }
            }



            return(View());
        }
예제 #17
0
        public ActionResult createMessage(message message)
        {
            message.msg_time = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.message.Add(message);
                db.SaveChanges();
                return(RedirectToRoute(new { controller = "web_activities", action = "Details", id = message.tourism_id }));
            }

            return(RedirectToRoute(new { controller = "web_activities", action = "Details", id = message.tourism_id }));
        }
예제 #18
0
        public ActionResult Create(badge badge, HttpPostedFileBase badge_photo)
        {
            if (ModelState.IsValid)
            {
                string fileName = "";
                if (badge_photo != null)
                {
                    if (badge_photo.ContentLength > 0)
                    {
                        fileName = System.IO.Path.GetFileName(badge_photo.FileName);       //取得檔案的檔名(主檔名+副檔名)
                        badge_photo.SaveAs(Server.MapPath("~/images/badges/" + fileName)); //將檔案存到該資料夾
                    }
                }
                badge.badge_photo = fileName;

                db.badge.Add(badge);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(badge));
        }
예제 #19
0
        public void LoadJson()
        {
            using (StreamReader r = new StreamReader(@"D:\TravelCAT\TravelCat\hotel_C_f.json"))
            {
                var json = r.ReadToEnd();

                tourism_photo tp = new tourism_photo();

                List <Rootobject> rt = JsonConvert.DeserializeObject <List <Rootobject> >(json);

                for (int i = 0; i < rt.Count; i++)
                {
                    hotel items = new hotel();
                    items.hotel_id       = db.Database.SqlQuery <string>("Select dbo.GethotelId()").FirstOrDefault();
                    items.hotel_intro    = rt[i].Description;
                    items.hotel_tel      = rt[i].Tel;
                    items.hotel_title    = rt[i].Name;
                    items.latitude       = rt[i].Py.ToString();
                    items.longitude      = rt[i].Px.ToString();
                    items.website        = rt[i].Website;
                    items.address_detail = rt[i].Add;
                    items.city           = rt[i].Region;
                    items.district       = rt[i].Town;

                    if (rt[i].Picture1 != "")
                    {
                        tp.tourism_id     = items.hotel_id;
                        tp.tourism_photo1 = rt[i].Picture1;
                        db.tourism_photo.Add(tp);
                    }
                    if (rt[i].Picture2 != "")
                    {
                        tp.tourism_id     = items.hotel_id;
                        tp.tourism_photo1 = rt[i].Picture2;
                        db.tourism_photo.Add(tp);
                    }
                    if (rt[i].Picture3 != "")
                    {
                        tp.tourism_id     = items.hotel_id;
                        tp.tourism_photo1 = rt[i].Picture3;
                        db.tourism_photo.Add(tp);
                    }

                    db.hotel.Add(items);
                    db.SaveChanges();
                }

                Console.WriteLine("success");
            }
        }
예제 #20
0
        public ActionResult ResetPwd(string id, string newpassword)
        {
            member member = db.member.Find(id);

            byte[] password     = System.Text.Encoding.UTF8.GetBytes(newpassword);
            byte[] hash         = new System.Security.Cryptography.SHA256Managed().ComputeHash(password);
            string hashpassword = Convert.ToBase64String(hash);

            member.member_password = hashpassword;

            if (ModelState.IsValid)
            {
                db.Entry(member).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Login", "Home"));
            }

            return(View());
        }
예제 #21
0
        [HttpPost]                                                                      //預設就是httpget,這裡是要讓他新增資料到資料庫
        public ActionResult Create(activity activity, HttpPostedFileBase tourism_photo) //多載(overloading/overloading)
        {
            string act_id = db.Database.SqlQuery <string>("Select dbo.GetactivityId()").FirstOrDefault();

            activity.activity_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/activity/" + fileName)); //將檔案存到該資料夾
                }
            }
            //end
            tourism_photo tp = new tourism_photo();

            tp.tourism_photo1 = fileName;
            tp.tourism_id     = activity.activity_id;

            db.activities.Add(activity);
            db.SaveChanges();
            db.tourism_photo.Add(tp);
            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                var entityError      = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var getFullMessage   = string.Join("; ", entityError);
                var exceptionMessage = string.Concat(ex.Message, "errors are: ", getFullMessage);
                //NLog
                return(View(exceptionMessage.ToString()));
            }

            return(RedirectToAction("Index"));
        }
예제 #22
0
        // GET: ImportTEST
        public void LoadJson()
        {
            using (StreamReader r = new StreamReader(@"D:\TravelCAT\TravelCat\activity_C_f.json"))
            {
                var json             = r.ReadToEnd();
                List <Rootobject> rt = JsonConvert.DeserializeObject <List <Rootobject> >(json);

                for (int i = 0; i < rt.Count; i++)
                {
                    activity items = new activity();
                    items.activity_id    = db.Database.SqlQuery <string>("Select dbo.GetactivityId()").FirstOrDefault();
                    items.activity_intro = rt[i].Description;
                    items.activity_tel   = rt[i].Tel;
                    items.activity_title = rt[i].Name;
                    items.latitude       = rt[i].Py.ToString();
                    items.longitude      = rt[i].Px.ToString();
                    items.website        = rt[i].Website;
                    items.address_detail = rt[i].Add;
                    items.city           = rt[i].Region;
                    items.district       = rt[i].Town;
                    items.begin_date     = rt[i].Start.ToString();
                    items.end_date       = rt[i].End.ToString();
                    items.organizer      = rt[i].Org;
                    items.transport_info = rt[i].Travellinginfo;

                    //if (rt[i].Picture1 != "")
                    //{
                    //    tourism_photo tp = new tourism_photo();
                    //    tp.tourism_id = items.activity_id;
                    //    tp.tourism_photo1 = rt[i].Picture1;
                    //    db.tourism_photo.Add(tp);
                    //}
                    //if (rt[i].Picture2 != "")
                    //{
                    //    tourism_photo tp = new tourism_photo();
                    //    tp.tourism_id = items.activity_id;
                    //    tp.tourism_photo1 = rt[i].Picture2;
                    //    db.tourism_photo.Add(tp);
                    //}
                    //if (rt[i].Picture3 != "")
                    //{
                    //    tourism_photo tp = new tourism_photo();
                    //    tp.tourism_id = items.activity_id;
                    //    tp.tourism_photo1 = rt[i].Picture3;
                    //    db.tourism_photo.Add(tp);
                    //}

                    //db.activity.Add(items);
                    //try
                    //{
                    //    db.SaveChanges();
                    //}
                    //catch (DbEntityValidationException ex)
                    //{
                    //    var entityError = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                    //    var getFullMessage = string.Join("; ", entityError);
                    //    var exceptionMessage = string.Concat(ex.Message, "errors are: ", getFullMessage);
                    //    //NLog
                    //    Console.WriteLine(exceptionMessage.ToString());

                    //}



                    if (String.IsNullOrEmpty(rt[i].Picture1) != true)
                    {
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_id     = items.activity_id;
                        tp.tourism_photo1 = rt[i].Picture1;
                        db.tourism_photo.Add(tp);
                    }
                    if (String.IsNullOrEmpty(rt[i].Picture2) != true)
                    {
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_id     = items.activity_id;
                        tp.tourism_photo1 = rt[i].Picture2;
                        db.tourism_photo.Add(tp);
                    }
                    if (String.IsNullOrEmpty(rt[i].Picture3) != true)
                    {
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_id     = items.activity_id;
                        tp.tourism_photo1 = rt[i].Picture3;
                        db.tourism_photo.Add(tp);
                    }

                    db.activity.Add(items);
                    db.SaveChanges();
                }

                Console.WriteLine("success");
            }
        }
예제 #23
0
        public void LoadJson()
        {
            using (StreamReader r = new StreamReader(@"D:\TravelCAT\TravelCat\restaurant_C_f.json"))
            {
                var json             = r.ReadToEnd();
                List <Rootobject> rt = JsonConvert.DeserializeObject <List <Rootobject> >(json);

                for (int i = 0; i < rt.Count; i++)
                {
                    restaurant items = new restaurant();
                    items.restaurant_id    = db.Database.SqlQuery <string>("Select dbo.GetrestId()").FirstOrDefault();
                    items.restaurant_intro = rt[i].Description;
                    items.restaurant_tel   = rt[i].Tel;
                    items.restaurant_title = rt[i].Name;
                    items.latitude         = rt[i].Py.ToString();
                    items.longitude        = rt[i].Px.ToString();
                    items.open_time        = rt[i].Opentime;
                    items.address_detail   = rt[i].Add;
                    items.city             = rt[i].Region;
                    items.district         = rt[i].Town;

                    //if (String.IsNullOrEmpty(rt[i].Picture1) != true)
                    //{
                    //    tp.tourism_id = items.restaurant_id;
                    //    tp.tourism_photo1 = rt[i].Picture1;
                    //    db.tourism_photo.Add(tp);
                    //}
                    //if (String.IsNullOrEmpty(rt[i].Picture2) != true)
                    //{
                    //    tp.tourism_id = items.restaurant_id;
                    //    tp.tourism_photo1 = rt[i].Picture2;
                    //    db.tourism_photo.Add(tp);
                    //}
                    //if (String.IsNullOrEmpty(rt[i].Picture3) != true)
                    //{
                    //    tp.tourism_id = items.restaurant_id;
                    //    tp.tourism_photo1 = rt[i].Picture3;
                    //    db.tourism_photo.Add(tp);
                    //}
                    if (String.IsNullOrEmpty(rt[i].Picture1) != true)
                    {
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_id     = items.restaurant_id;
                        tp.tourism_photo1 = rt[i].Picture1;
                        db.tourism_photo.Add(tp);
                    }
                    if (String.IsNullOrEmpty(rt[i].Picture2) != true)
                    {
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_id     = items.restaurant_id;
                        tp.tourism_photo1 = rt[i].Picture2;
                        db.tourism_photo.Add(tp);
                    }
                    if (String.IsNullOrEmpty(rt[i].Picture3) != true)
                    {
                        tourism_photo tp = new tourism_photo();
                        tp.tourism_id     = items.restaurant_id;
                        tp.tourism_photo1 = rt[i].Picture3;
                        db.tourism_photo.Add(tp);
                    }

                    db.restaurant.Add(items);
                    db.SaveChanges();
                }

                Console.WriteLine("success");
            }
        }