public int Delete(int id) { USER user = db.USERS.Find(id); COMMENT cm = db.COMMENTS.Where(c => c.ID_USER == id).FirstOrDefault(); if (cm != null) { return(-1); } POST Post = db.POSTs.Where(c => c.ID_USER == id).FirstOrDefault(); if (Post != null) { return(-1); } using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { db.USERS.Remove(user); int i = db.SaveChanges(); transaction.Commit(); return(i); } catch { transaction.Rollback(); return(0); } } }
public ActionResult DetailPost(int id, int?page) { POST Post = postsModels.GetItem(id); ViewBag.Post = postsModels.GetItem(id); ViewBag.SamePost = postsModels.GetItemActiveSame(1, 5, Post.ID_CATEGORY, id); ViewBag.RencentPost = postsModels.GetItemActive(1, 5, id); ViewBag.Active = "category"; ViewBag.Vote = 0; if (User.GetType() == typeof(CustomPrincipal)) { CustomPrincipal prin = (CustomPrincipal)User; VOTE Vote = voteModels.GetItemPostUser(Post.ID, prin.ID); if (Vote != null) { ViewBag.Vote = 1; } else { ViewBag.Vote = 2; } } IPagedList ListCommentPost = commentsModels.GetItemsPost(page ?? 1, 12, id); return(View(ListCommentPost)); }
public int EditItem(int id, POST Post) { POST PostEdit = db.POSTs.Find(id); using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { PostEdit.TITLE = Post.TITLE; PostEdit.URL_SLUG = ConvertString.ToUrlSlug(Post.TITLE); PostEdit.DATE_EDIT = DateTime.Now; PostEdit.ACTIVE = Post.ACTIVE; PostEdit.DESCRIPTION = Post.DESCRIPTION; PostEdit.DETAIL = Post.DETAIL; PostEdit.PICTURE = Post.PICTURE; db.Entry(PostEdit).State = EntityState.Modified; int i = db.SaveChanges(); transaction.Commit(); return(Post.ID); } catch { transaction.Rollback(); return(0); } } }
public ActionResult postBoard(string kw, string sw, string dw) { var model = conn.POST.OrderByDescending(x => x.P_DATETIME).ToList(); if (!string.IsNullOrEmpty(kw)) { if (kw == "all") { return(PartialView("~/Areas/Admin/Views/aboutPost/postBoard.cshtml", model)); } else { model = model.Where(x => x.P_BOARDNAME.Contains(kw)).ToList(); } } if (!string.IsNullOrEmpty(sw)) { model = conn.POST .Where(c => c.P_Title.Contains(sw) || c.P_CONTENTS.Contains(sw) || c.P_POSTER.Contains(sw) || c.P_BOARDNAME.Contains(sw)) .OrderByDescending(a => a.P_CLICK) .ToList(); } if (!string.IsNullOrEmpty(dw)) { int id = System.Convert.ToInt32(dw); POST post = conn.POST.Find(id); conn.POST.Remove(post); conn.SaveChanges(); } return(PartialView("~/Areas/Admin/Views/aboutPost/postBoard.cshtml", model)); }
public IHttpActionResult PutPOST(int id, POST pOST) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pOST.MA_BAI_VIET) { return(BadRequest()); } db.Entry(pOST).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!POSTExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "text")] POST pOST, HttpPostedFileBase file) { if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); string name = pic.Substring(0, pic.IndexOf('.')); string ext = pic.Substring(pic.IndexOf('.')); int result = (int)DateTime.Now.Subtract(DateTime.MinValue).TotalSeconds; pic = name + result.ToString() + ext; string path = System.IO.Path.Combine(Server.MapPath("~/image/posts"), pic); file.SaveAs(path); pOST.picture = pic; using (MemoryStream ms = new MemoryStream()) { file.InputStream.CopyTo(ms); byte[] array = ms.GetBuffer(); } } if (ModelState.IsValid && pOST != null) { pOST.UserInfo = db.AspNetUsers.First(u => u.UserName == User.Identity.Name).UserInfo; pOST.created_at = DateTime.Now; db.POSTs.Add(pOST); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pOST)); }
public IHttpActionResult PostPOST(POST pOST) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } POST baiviet = new POST(); baiviet.TIEU_DE_BAI_VIET = pOST.TIEU_DE_BAI_VIET; baiviet.NGAY_DANG_BAI = Convert.ToDateTime(DateTime.Today.ToShortDateString()); baiviet.NOI_DUNG_BAI_VIET = pOST.NOI_DUNG_BAI_VIET; baiviet.ANH_BAI_VIET = pOST.ANH_BAI_VIET; baiviet.NGUOI_DANG_BAI = pOST.NGUOI_DANG_BAI; db.POSTS.Add(baiviet); try { db.SaveChanges(); } catch (DbUpdateException) { if (POSTExists(baiviet.MA_BAI_VIET)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = baiviet.MA_BAI_VIET }, baiviet)); }
public POST GetPost(int postID) { POST post = new POST(); post = postRepo.Get(x => x.ID == postID); return(post); }
public IHttpActionResult PutPOST(int id, POST pOST) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != pOST.MA_BAI_VIET) { return BadRequest(); } var baiviet = db.POSTS.Where(x => x.MA_BAI_VIET == id).FirstOrDefault(); baiviet.TIEU_DE_BAI_VIET = pOST.TIEU_DE_BAI_VIET; baiviet.NOI_DUNG_BAI_VIET = pOST.NOI_DUNG_BAI_VIET; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!POSTExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public ActionResult Delete(int id) { POST PostDelete = postsModels.GetItem(id); if (Check.checkPostDelete(PostDelete)) { string pictureOld = PostDelete.PICTURE; if (postsModels.DeleteItem(id) > 0) { var dataFile = Server.MapPath("~/Assets/Upload/Post/" + pictureOld); ImgUpload imgUpload = new ImgUpload(); imgUpload.Delete(dataFile); Session["mes"] = "Xóa thành công!!!"; } else { Session["mes_er"] = "Xóa thất bại"; } } else { Session["mes_er"] = "Xóa thất bại! không đủ quyền"; } return(RedirectToAction("Index", "PostManager")); }
public ActionResult createPost(string postContent, int ownerid, string action_, string controller_, HttpPostedFileBase attach) { POST post = new POST(); post.CONTENT = postContent; post.POSTDATE = DateTime.Now; post.LIKES = 0; post.USERID = ownerid; //upload attachments if (attach != null) { var fileName = Path.GetFileName(attach.FileName); var path = Path.Combine(Server.MapPath("~/Data/Posts_Attachments/"), fileName); attach.SaveAs(path); post.MEDIA = "../Data/Posts_Attachments/" + fileName; } var con = new SOCIALMEDIA_DBEntities(); var posts = con.POSTS.OrderByDescending(p => p.POSTID); post.POSTID = (posts.Count() != 0)? posts.First().POSTID + 1:1; con.POSTS.Add(post); con.SaveChanges(); return(RedirectToAction(action_, controller_, new { userid = ownerid })); }
public ActionResult Write(Write model) { var a = Request["count"]; var id = Session["userID"]; string ss; string pa = "~/unload/postPicture/"; ss = "p" + System.DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + Path.GetExtension(Request.Files["file"].FileName); var pp = Path.GetExtension(Request.Files["file"].FileName); Request.Files["file"].SaveAs(System.Web.HttpContext.Current.Server.MapPath(pa) + ss); if (ModelState.IsValid) { int na = System.Convert.ToInt32(model.B_NAME); var bn = conn.BOARD.FirstOrDefault(c => c.B_ID == na); POST post = new POST(); post.P_BOARDID = na; post.P_Title = model.P_Title; post.P_PICTURE = pp == "" ? "" : ss; post.P_CONTENTS = model.P_CONTENTS; post.P_POSTERID = (int)id; post.P_POSTER = Session["userName"].ToString(); post.P_CLICK = 0; post.P_DATETIME = DateTime.Parse(DateTime.Now.ToString()); post.P_BOARDNAME = bn.B_NAME; conn.POST.Add(post); conn.SaveChanges(); return(Content("<script>alert('你已发帖成功');window.location.href='/Home/Write'</script>")); } return(View(model)); }
public string getAccessToken(string client_id, string client_secret, string audience) { Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("client_id", client_id); body.Add("client_secret", client_secret); body.Add("audience", audience); body.Add("grant_type", "client_credentials"); // Need to do a POST to auth0 to get our credentials APIRequest credential_request = new POST(uri: "oauth/token", body: JsonConvert.SerializeObject(body)) .authorize(false); APIResponse response = execute(credential_request); Dictionary <string, string> responseData = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.ToString()); // Save token string access_token = responseData["access_token"]; return(access_token); }
public IHttpActionResult PostPOST_CATEGORIES(post_categories pOST_CATEGORIES) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } POST post = db.POSTS.Where(x => x.TIEU_DE_BAI_VIET == pOST_CATEGORIES.tieu_de_bai_viet).FirstOrDefault(); int ma_bai_viet = post.MA_BAI_VIET; POST_CATEGORIES p_cat = new POST_CATEGORIES(); p_cat.MA_BAI_VIET = ma_bai_viet; p_cat.MA_DANH_MUC = pOST_CATEGORIES.ma_danh_muc; db.POST_CATEGORIES.Add(p_cat); try { db.SaveChanges(); } catch (DbUpdateException) { if (POST_CATEGORIESExists(p_cat.ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = p_cat.ID }, p_cat)); }
public bool CreatePost(POST post) { bool returnValue = false; post.CREATED_DATE = DateTime.Now; returnValue = postRepo.Add(post); return(returnValue); }
public int GetPOST_CATEGORIES(string id) { POST post = db.POSTS.Where(x => x.TIEU_DE_BAI_VIET == id).FirstOrDefault(); int ma_bai_viet = post.MA_BAI_VIET; return(ma_bai_viet); }
private void btnRater_Click(object sender, EventArgs e) { if (!Application.OpenForms.OfType <POST>().Any()) { POST ps = new POST(); ps.Show(); } }
public ActionResult DeleteConfirmed(int id) { POST pOST = db.POSTs.Find(id); db.POSTs.Remove(pOST); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// POST https://api.opensuse.org/source/home:coolo:branches:openSUSE:Factory:staging/fam?opackage=fam&oproject=openSUSE:Factory&cmd=diff&rev=2&expand=1 /// </summary> /// <param name="SrcePrj"></param> /// <param name="SrcePkg"></param> /// <param name="DestPrj"></param> /// <param name="DestPkg"></param> /// <param name="Rev"></param> /// <returns>StringBuilder</returns> public static StringBuilder PostRequestDiff(string SrcePrj, string SrcePkg, string DestPrj, string DestPkg, string Rev) { string UrlCmd = "source/" + SrcePrj + "/" + SrcePkg + "?opackage=" + DestPkg + "&oproject=" + DestPrj + "&cmd=diff&rev=" + Rev + "&expand=1"; return(POST.Postit(UrlCmd, VarGlobal.User, VarGlobal.Password)); }
public ActionResult Delete(int Id) { POST post = conn.POST.Find(Id); conn.POST.Remove(post); conn.SaveChanges(); return(View()); }
// Use this for initialization void Start() { AppSoftware = GameObject.Find("Applications"); HackingSoftware = GameObject.Find("Hacking"); SysSoftware = GameObject.Find("System"); //Computer = GameObject.Find("Computer"); //System clk = SysSoftware.GetComponent <Clock>(); defalt = SysSoftware.GetComponent <Defalt>(); am = SysSoftware.GetComponent <AppMenu>(); cmd = SysSoftware.GetComponent <CLI>(); com = SysSoftware.GetComponent <Computer>(); sc = SysSoftware.GetComponent <SoundControl>(); appman = SysSoftware.GetComponent <AppMan>(); boot = SysSoftware.GetComponent <Boot>(); post = SysSoftware.GetComponent <POST>(); os = SysSoftware.GetComponent <OS>(); mouse = SysSoftware.GetComponent <Mouse>(); desk = SysSoftware.GetComponent <Desktop>(); //Applications al = AppSoftware.GetComponent <AccLog>(); sm = AppSoftware.GetComponent <SystemMap>(); ib = AppSoftware.GetComponent <InternetBrowser>(); //Hacking prog = HackingSoftware.GetComponent <Progtive>(); trace = HackingSoftware.GetComponent <Tracer>(); cy = HackingSoftware.GetComponent <Descy>(); ds = HackingSoftware.GetComponent <DirSearch>(); mb = GetComponent <MissionBrow>(); cc = GetComponent <CurContracts>(); sl = GetComponent <SiteList>(); note = GetComponent <Notepad>(); fav = GetComponent <Favs>(); tv = GetComponent <TreeView>(); mPass = GetComponent <MonitorBypass>(); wsv = GetComponent <WebSecViewer>(); sdp = GetComponent <ShutdownProm>(); Audio = GetComponent <AudioSource>(); windowRect.x = Customize.cust.windowx[windowID]; windowRect.y = Customize.cust.windowy[windowID]; Audio.volume = Customize.cust.Volume; DesktopY = -50; StartTime = 0.030f; Snap = false; if (Size == 0) { Size = 21; } }
public void sendData(string feedToken, string feedKey, string data) { object[] uriChunks = { feedToken, "ngest", feedKey }; APIRequest req = new POST(uri: String.Join("/", uriChunks), body: data) .authorize(false); // Ngest requests do not require authorization this.execute(req); }
public IHttpActionResult GetPOST(int id) { POST pOST = db.POSTS.Find(id); if (pOST == null) { return NotFound(); } return Ok(pOST); }
public int GetProfileOwnerID(int postID) { POST post = new POST(); using (var context = new PastebookEntities()) { post = context.POSTs.FirstOrDefault(p => p.ID == postID); } return(post.POSTER_ID); }
public POST GetPost(int postID) { POST post = new POST(); using (var context = new PastebookEntities()) { post = context.POSTs.Include("LIKEs").Include("COMMENTs").Include("USER").Include("USER1").Include("COMMENTs.USER").Include("LIKEs.USER").FirstOrDefault(p => p.ID == postID); } return(post); }
public ActionResult Edit([Bind(Include = "post_id,text,picture,created_at")] POST pOST) { if (ModelState.IsValid) { pOST.created_at = TimeSpan.Parse(DateTime.Now.ToString()); db.Entry(pOST).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pOST)); }
public ActionResult Create([Bind(Include = "post_id,text,picture,created_at")] POST pOST) { if (ModelState.IsValid) { db.POSTs.Add(pOST); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pOST)); }
public ActionResult Edit([Bind(Include = "ID,LINK,SEO_TITLE,SEO_DESCRIPTION,IMG_DESCRIPTION,TEXT_DESCRIPTION,CONTENT,DATE_CREATE,AUTHOR,VIEW_NUMBER,CATEGORY,POST_STATE,TITLE,IMG")] POST pOST) { if (ModelState.IsValid) { db.Entry(pOST).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CATEGORY = new SelectList(db.CATEGORies, "ID", "category_name", pOST.CATEGORY); return(View(pOST)); }
public ActionResult Edit([Bind(Include = "text,picture")] POST pOST) { if (ModelState.IsValid) { pOST.created_at = DateTime.Now; db.Entry(pOST).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pOST)); }
public async Task <APIResponse> sendDataAsync(string feedToken, string feedKey, string data) { object[] uriChunks = { feedToken, "ngest", feedKey }; APIRequest req = new POST(uri: String.Join("/", uriChunks), body: data) .authorize(false); // Ngest requests do not require authorization var response = await this.executeAsync(req); return(response); }
public ActionResult Create(POST post) { if (ModelState.IsValid) { db.POSTs.Add(post); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Ma_phim = new SelectList(db.PHIMs, "Ma_phim", "Ten_phim", post.Ma_phim); ViewBag.Ten_tai_khoan = new SelectList(db.TAIKHOANs, "Ten_tai_khoan", "Mat_khau", post.Ten_tai_khoan); return View(post); }
public static void AddQuocGia(POST post, String quocgia) { if (db != null) { CloseConnection(); } CreateConnection(); if (quocgia != null) { POST_QUOCGIA item = new POST_QUOCGIA(); item.Ma_bai_post = post.Ma_bai_post; item.Ma_quoc_gia = QuocGiaBLL.GetQuocGia(quocgia).Ma_quoc_gia; //item.QUOCGIA = QuocGiaBLL.GetQuocGia(quocgia); //db.POSTs.Find(post.Ma_bai_post).POST_QUOCGIA.Add(item); db.POST_QUOCGIA.Add(item); db.SaveChanges(); } }
public static void AddHinhAnh(POST post, List<String> hinhanhlist) { if (db != null) { CloseConnection(); } CreateConnection(); if (hinhanhlist != null) { foreach (String duong_dan in hinhanhlist) { POST_HINHANH item = new POST_HINHANH(); item.Ma_bai_post = post.Ma_bai_post; item.Duong_dan = duong_dan; db.POSTs.Find(post.Ma_bai_post).POST_HINHANH.Add(item); db.SaveChanges(); } } }
public static void AddTheLoai(POST post, List<String> theloailist) { if (db != null) { CloseConnection(); } CreateConnection(); if (theloailist != null) { foreach (String ma_the_loai in theloailist) { POST_THELOAI item = new POST_THELOAI(); item.Ma_bai_post = post.Ma_bai_post; item.Ma_the_loai = TheLoaiBLL.GetTheLoai(ma_the_loai).Ma_the_loai; //item.THELOAI = TheLoaiBLL.GetTheLoai(ma_the_loai); //db.POSTs.Find(post.Ma_bai_post).POST_THELOAI.Add(item); db.POST_THELOAI.Add(item); db.SaveChanges(); } } }
if ( isset ($_POST['action']) ) { if($_POST['action'] == "Upload Image") {
public static void CreatePost(Object userId,String TenBaiPost, String NoiDung, DateTime NamSanXuat, String DaoDien, String DienVien, String LinkTrailer, String LinkDownLoad, double DiemDanhGia, String AnhDaiDien, List<String> ListTheLoai, List<String> AlbumAnh, String MaQuocGia) { if (db != null) { CloseConnection(); } CreateConnection(); if (CheckTitle(TenBaiPost) == false) { POST post = new POST(); post.UserId = (System.Guid)userId; post.Ten_bai_post = TenBaiPost; post.Mo_ta = NoiDung; post.Nam_san_xuat = NamSanXuat; post.Dao_dien = DaoDien; post.Dien_vien = DienVien; post.Trailer_link = LinkTrailer; post.Download_link = LinkDownLoad; post.Diem_danh_gia = DiemDanhGia; post.Anh_dai_dienn = AnhDaiDien; post.Ngay_post = DateTime.Now; db.POSTs.Add(post); db.SaveChanges(); AddTheLoai(post, ListTheLoai); AddHinhAnh(post, AlbumAnh); AddQuocGia(post, MaQuocGia); } }
public ActionResult Edit(POST post, int id) { if (ModelState.IsValid) { post.Ma_bai_post = id; db.Entry(post).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Ma_phim = new SelectList(db.PHIMs, "Ma_phim", "Ten_phim", post.Ma_phim); ViewBag.Ten_tai_khoan = new SelectList(db.TAIKHOANs, "Ten_tai_khoan", "Ten_tai_khoan", post.Ten_tai_khoan); return View(post); }