public ActionResult fileupload(IEnumerable<HttpPostedFileBase> file) { foreach (var f in file) { if (f != null && f.ContentLength > 0 ) { string pcki = Convert.ToString(Request["pck"]); string extension = Path.GetExtension(f.FileName); var fileName = Path.GetFileName(f.FileName); var p = Server.MapPath("~/Content/Album/"); Directory.CreateDirectory(p); //var fileName = f + extension; var path = Path.Combine(p, fileName); f.SaveAs(path); using (var fileup = new TourCrowDBEntities()) { var qry = new IMAGE {Path = path}; fileup.IMAGEs.Add(qry); } } else { ViewBag.PropicError = "Invalid Photo"; } } //return RedirectToAction("Index", HttpContext.User.Identity.Name.Split('|')[1].ToString()); return View("Index"); }
public ActionResult Index() { string username = Convert.ToString(Request["userName"]); string fbId = Convert.ToString(Request["fbId"]); string packName; packId= Convert.ToInt32(Request["packid"]); ViewBag.packID = packId; DateTime now = DateTime.Now; ViewBag.name = username; ViewBag.id = fbId; if (Request["packName"] == "") { packName = DateTime.Now.ToString(); } else { packName = Convert.ToString(Request["packName"]); } if (username.IsNullOrWhiteSpace()) { ViewBag.Title = username + "Profile"; } else { ViewBag.Title = username + " | Profile"; } ViewBag.username = username; ViewBag.fbID = fbId; string email = Convert.ToString(Request["fbEmail"]); //Response.Write(email+"</br>"); string[] pids = Request.QueryString.GetValues("pid"); string[] photos = Request.QueryString.GetValues("photoid"); //Response.Write(username + "</br>" + fbId + "</br>"+pids[0]); using (var context = new TourCrowDBEntities()) { //var query = from usr in tcdb.USERs where usr.UserFBID == fbId select usr; //var chkusr = query.Count(); //Response.Write(chkusr); try { var query = from usr in context.USERs where usr.UserFBID == fbId select usr; var chkusr = query.Count(); if (chkusr > 0 && pids.Length > 0) { insertPackage(pids, fbId, username, photos, packName, now); } else if (chkusr <= 0 && pids.Length > 0) { var user_insert_query = new USER { UserName = username, UserFBID = fbId }; context.USERs.Add(user_insert_query); context.SaveChanges(); insertPackage(pids, fbId, username, photos, packName, now); } } catch (Exception) { //Response.Write("No Place Selected"); } } showPackages(fbId); getPackageInfo(fbId,packId); return View(); }
private void insertPackage(string[] pids,string fbId,string username,string[] photos, string packName, DateTime now) { //insert package using (var dbcon = new TourCrowDBEntities()) { var pack_insert_query = new PACKAGE {UserFBID = fbId, Date = now, Title = packName}; dbcon.PACKAGEs.Add(pack_insert_query); dbcon.SaveChanges(); //( packName.ToString() == null ? Convert.ToString(DateTime.Now) : packName.ToString() ) //get package id var get_packid = from pckid in dbcon.PACKAGEs where pckid.UserFBID == fbId.ToString() select pckid.PackageID; var packid = get_packid.AsEnumerable().LastOrDefault(); for (int i = 0, j = 0; i < pids.Count() && j < photos.Count(); i++, j++) { var userpack_insert_query = new USER_PACKAGE { PackageID = Convert.ToInt32(packid), PlaceID = pids[i], PhotoKey = photos[i] }; dbcon.USER_PACKAGE.Add(userpack_insert_query); dbcon.SaveChanges(); } } }
private void getPackageInfo(String fbId, int packId) { using (var pack = new TourCrowDBEntities()) { var pck_id = from p in pack.USER_PACKAGE where p.PackageID == packId select p.PlaceID; var pck_count = pck_id.ToList(); ViewBag.pck_count = pck_id.Count(); List<string> pname = new List<string>(); List<string> padd = new List<string>(); List<string> pimg = new List<string>(); int i = 0; foreach (var placeId in pck_count) { String json = place_details(placeId); ProfilePageModel.RootObject model = parseData(json); pname.Add(model.result.name); padd.Add(model.result.formatted_address); pimg.Add(model.result.photos[0].photo_reference); i++; } ViewBag.pname = pname; ViewBag.padd = padd; ViewBag.pimg = pimg; } }
public void showPackages(string fbId_new) { using (var packcon = new TourCrowDBEntities()) { var pck_name = from pck in packcon.PACKAGEs where pck.UserFBID == fbId_new.ToString() select pck.Title; var check_pack_nm = pck_name.ToList(); ViewBag.count_pack = pck_name.Count(); //Response.Write(pck_name.Count()); ViewBag.packages = check_pack_nm; var pck_id = from pid in packcon.PACKAGEs where pid.UserFBID == fbId_new select pid.PackageID; var check_pid = pck_id.ToList(); ViewBag.pid = check_pid; } //return ("Index"); }
public ActionResult Index() { ViewBag.Title = "Plan"; ViewBag.activePage = "Plan"; string username = Convert.ToString(Request["userName"]); string fbId = Convert.ToString(Request["fbId"]); string packName; packId = Convert.ToInt32(Request["packid"]); ViewBag.packID = packId; DateTime now = DateTime.Now; ViewBag.name = username; ViewBag.id = fbId; search_val = Convert.ToString(Request["search"]) == null ? "null" : Convert.ToString(Request["search"]); ViewBag.pageGetValue = search_val; string email = Convert.ToString(Request["fbEmail"]); //Response.Write(email+"</br>"); string[] pids = Request.QueryString.GetValues("pid"); string[] photos = Request.QueryString.GetValues("photoid"); if (Request["packName"] == "") { packName = DateTime.Now.ToString(); } else { packName = Convert.ToString(Request["packName"]); } using (var context = new TourCrowDBEntities()) { //var query = from usr in tcdb.USERs where usr.UserFBID == fbId select usr; //var chkusr = query.Count(); //Response.Write(chkusr); try { var query = from usr in context.USERs where usr.UserFBID == fbId select usr; var chkusr = query.Count(); if (chkusr > 0 && pids.Length > 0) { insertPackage(pids, fbId, username, photos, packName, now); } else if (chkusr <= 0 && pids.Length > 0) { var user_insert_query = new USER { UserName = username, UserFBID = fbId }; context.USERs.Add(user_insert_query); context.SaveChanges(); insertPackage(pids, fbId, username, photos, packName, now); } } catch (Exception) { //Response.Write("No Place Selected"); } } return View(); }