static public List <CONTENT> GetRelatedArticle(string uid, string siteid) { DateTime dt = DateTime.Now; List <CONTENT> contentitems = new List <CONTENT>(); using (livee_11Entities database = new livee_11Entities()) { var query = from CONTENT_GROUP in database.CONTENT_GROUP join CONTENT_ITEM_CONTENT_GROUP in database.CONTENT_ITEM_CONTENT_GROUP on CONTENT_GROUP.CONTENT_GROUP_UID equals CONTENT_ITEM_CONTENT_GROUP.CONTENT_GROUP_UID where CONTENT_ITEM_CONTENT_GROUP.CONTENT_ITEM_UID.Equals(uid) && CONTENT_ITEM_CONTENT_GROUP.SITE_UID.Equals(siteid) && CONTENT_GROUP.CONTENT_GROUP_TYPE_UCODE.Equals("PACKAGE") select new { CONTENT_ITEM_CONTENT_GROUP.CONTENT_GROUP_UID, CONTENT_GROUP.GROUP_NAME }; foreach (var v in query) { string groupuid = v.CONTENT_GROUP_UID; var query2 = from CONTENT_ITEM in database.CONTENT_ITEM join CONTENT_ITEM_CONTENT_GROUP in database.CONTENT_ITEM_CONTENT_GROUP on CONTENT_ITEM.CONTENT_ITEM_UID equals CONTENT_ITEM_CONTENT_GROUP.CONTENT_ITEM_UID where CONTENT_ITEM_CONTENT_GROUP.CONTENT_GROUP_UID.Equals(groupuid) && CONTENT_ITEM_CONTENT_GROUP.SITE_UID.Equals(siteid) && CONTENT_ITEM.STATE_UCODE.Equals("PRODDEPLOY") && (CONTENT_ITEM.CONTENT_TYPE_UID.Equals(102) || CONTENT_ITEM.CONTENT_TYPE_UID.Equals(127)) && CONTENT_ITEM_CONTENT_GROUP.DISPLAY_START_DATE < dt select new { CONTENT_ITEM.CONTENT_ITEM_UID }; foreach (var vv in query2) { CONTENT c = new CONTENT(); c.uid = vv.CONTENT_ITEM_UID; contentitems.Add(c); } } } return(contentitems.Take(10).ToList()); } // GetRelatedArticle
public bool Update(CONTENT entity) { try { var content = db.CONTENT.Find(entity.ID); content.Name = entity.Name; content.Metatitle = entity.Metatitle; content.Description = entity.Description; content.Image = entity.Image; content.Detail = entity.Detail; content.CreatedDate = DateTime.Now; content.CreatedBy = entity.CreatedBy; content.ModifielDate = entity.ModifielDate; content.ModifielBy = entity.ModifielBy; content.MetaKeywords = entity.MetaKeywords; content.MetaDescriptions = entity.MetaDescriptions; content.Language = entity.Language; content.Status = entity.Status; db.SaveChanges(); return(true); } catch (Exception) { //logging return(false); } }
public ActionResult Create(CONTENT ct) { var dao = new ContentDao(); int inserted = dao.Insert(ct); return(View()); }
public int Insert(CONTENT ct) { //if (ModelState.IsValid) { CONTENT obj = new CONTENT(); //var author = new AccountDao().getByUserName((string)HttpContext.Current.Session["USER_SESSION"]); //string author_name = author.full_name; obj.author = 1; obj.meta_title = ct.meta_title; obj.title = ct.title; obj.desciption = ct.desciption; obj.image = ct.image; obj.detail = ct.detail; obj.created_date = DateTime.Now; obj.status = ct.status; if (ct.top_hot == null) { obj.top_hot = DateTime.Now.AddDays(7); } else { obj.top_hot = ct.top_hot; } obj.view_count = 0; obj.tags = ct.tags; db.CONTENT.Add(obj); db.SaveChanges(); } return(1); }
public HttpResponseMessage Put(int contentID, [FromBody] CONTENT CONTENT) { try { using (knowhauEntities entities = new knowhauEntities()) { CONTENT entity = new CONTENT(); entity = entities.CONTENTs.FirstOrDefault(e => e.contentID == contentID); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Content with id " + contentID.ToString() + " not found to update")); } else { entity.beaconID = CONTENT.beaconID; entity.contentID = CONTENT.contentID; entity.contentmsg = CONTENT.contentmsg; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
private void _postQuestion(OOPEZZ_DBEntities db, QUESTION question, BotMessageReceivedRequest mess) { ANSWER answer = db.ANSWER.Where(x => x.QUESTION_FK == question.PK_SEQ).OrderByDescending(x => x.STATUS).First(); String json = ""; json = fbTemplate.SimpleTextTemplate(mess.sender.id, "Câu hỏi : "); _post(json); json = fbTemplate.SimpleTextTemplate(mess.sender.id, question.QUESTION_TEXT); _post(json); String answer_pkseq_contents = answer.ANSWER_TEXT; char[] charac = { '#' }; List <String> pkseqs = answer_pkseq_contents.Split(charac).ToList(); List <CONTENT> contents = new List <CONTENT>(); foreach (String pkseq in pkseqs) { int pk = int.Parse(pkseq); CONTENT ct = db.CONTENT.Where(x => x.PK_SEQ == pk).First(); contents.Add(ct); } _sendContentList(db, contents, mess.sender.id); //json = fbTemplate.ButtonTemplate(mess.sender.id, "Bấm nút bên dưới để tiếp tục bài học nhé", new List<ResponseButtons>() { // new ResponseButtons() // { // type = "postback", // title = "Tiếp tục bài học", // payload = "" // } //}); }
/// <summary> /// 新增資料表CONTENT,採用CONTENTs模組 /// </summary> /// <param name="_Newdata"></param> public void Create(CONTENT _Newdata) { //將資料加入資料表 db.CONTENTs.Add(_Newdata); //儲存資料庫變更 db.SaveChanges(); }
public int Insert(CONTENT ct) { //if (ModelState.IsValid) { CONTENT obj = new CONTENT(); obj.author_ID = 0; obj.meta_title = ct.meta_title; obj.title = ct.title; obj.desciption = ct.desciption; obj.image = ct.image; obj.detail = ct.detail; obj.created_date = DateTime.Now; obj.status = ct.status; if (ct.top_hot == null) { obj.top_hot = DateTime.Now.AddDays(7); } else { obj.top_hot = ct.top_hot; } obj.view_count = ct.view_count; obj.tags = ct.tags; db.CONTENT.Add(obj); db.SaveChanges(); } return(1); }
public ActionResult DeleteConfirmed(int id) { CONTENT cONTENT = db.CONTENT.Find(id); db.CONTENT.Remove(cONTENT); db.SaveChanges(); return(RedirectToAction("Index")); }
private void _postContentformContent(OOPEZZ_DBEntities db, BotMessageReceivedRequest mess) { char[] spa = { '_' }; String content = mess.postback.payload.Split(spa)[1]; int content_pk = int.Parse(content); CONTENT ct = db.CONTENT.Where(x => x.PK_SEQ == content_pk).First(); List <CONTENT> contents = db.CONTENT.Where(x => x.GROUP_CONTENT_FK == ct.GROUP_CONTENT_FK && x.STT >= ct.STT).OrderBy(x => x.STT).ToList(); _postContentList(db, contents, mess.sender.id); }
public ActionResult Edit([Bind(Include = "PK_SEQ,STT,CONTENT_TEXT,TYPE,GROUP_CONTENT_FK")] CONTENT cONTENT) { if (ModelState.IsValid) { db.Entry(cONTENT).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cONTENT)); }
public ActionResult Index(FormCollection data) { if (data["action"].ToString().Equals("New")) { CONTENT content = new CONTENT() { GROUP_CONTENT_FK = int.Parse(data["groupcontent"]), CONTENT_TEXT = data["content"], TYPE = int.Parse(data["type"]) }; int? max = 0; CONTENT ct = db.CONTENT.Where(x => x.GROUP_CONTENT_FK == content.GROUP_CONTENT_FK).OrderByDescending(x => x.STT).FirstOrDefault(); if (ct == null) { max = 0; } else { max = ct.STT; } max++; content.STT = max; Create(content); } String sql = "SELECT* FROM dbo.CONTENT WHERE 1 = 1 "; String groupcontentfk = data["groupcontent"]; if (!groupcontentfk.Equals("")) { sql += " AND GROUP_CONTENT_FK = " + groupcontentfk; } List <GROUP_CONTENT> lg = db.GROUP_CONTENT.OrderByDescending(x => x.PK_SEQ).ToList(); IEnumerable <SelectListItem> listgroupcontent = lg.Select(x => new SelectListItem() { Text = x.NAME, Value = x.PK_SEQ.ToString() }); if (data["action"].ToString().Equals("New")) { foreach (var gcontent in listgroupcontent) { if (gcontent.Value.Equals(data["groupcontent"])) { gcontent.Selected = true; break; } } } ViewBag.listgroupcontent = listgroupcontent; return(View(db.CONTENT.SqlQuery(sql).ToList())); }
public ActionResult Create([Bind(Include = "PK_SEQ,STT,CONTENT_TEXT,TYPE,GROUP_CONTENT_FK")] CONTENT cONTENT) { if (ModelState.IsValid) { db.CONTENT.Add(cONTENT); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cONTENT)); }
public int Insert(CONTENT c) { using (SqlConnection conn = new SqlConnection(connstring)) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = string.Format(@"INSERT INTO T_CONTENT (C_NAME,C_TELEPHONE,C_MAIL,C_CONTENT,C_DATE) VALUES (N'{0}','{1}','{2}',N'{3}','{4}')", c.C_NAME, c.C_TELEPHONE, c.C_MAIL, c.C_CONTENT, DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")); return(cmd.ExecuteNonQuery()); } } }
/// <summary> /// Add a new content /// </summary> /// <param name="name">Name of the content</param> /// <param name="file">Text of the content</param> /// <param name="userId">ID of the owner</param> public void AddNewContent(string name, string file, int userId) { var newContent = new CONTENT() { name = name, file = file, userID = userId }; this.entities.CONTENT.Add(newContent); this.entities.SaveChanges(); }
/// <summary> /// 加入留言內容(Smoothdb的CONTENT table) /// </summary> /// <param name="_name"></param> /// <param name="_content"></param> public void Create_Conent(string _name, string _content) { CONTENT adddata = new CONTENT(); //資料繫結 adddata.name = _name; adddata.content1 = _content; //將資料加入content資料表中 //db.ContentModels.Add(adddata); db.CONTENTs.Add(adddata); db.SaveChanges(); }
public void CreateLinesFromBuffer_When2LinesInCharArray_ThenLinesAreCorrectlySeparated() { const string LINE_1 = "123456"; const string LINE_2 = "789"; const string CONTENT = LINE_1 + "\r\n" + LINE_2 + "\r\n"; char[] buffer = CONTENT.ToCharArray(); var result = _sut.CreateLinesFromBuffer(buffer, buffer.Length); Assert.AreEqual(2, result.Count); Assert.AreEqual(LINE_1, result[0]); Assert.AreEqual(LINE_2, result[1]); }
// GET: CONTENTs/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CONTENT cONTENT = db.CONTENT.Find(id); if (cONTENT == null) { return(HttpNotFound()); } return(View(cONTENT)); }
public void SetContent(CONTENT content, Sprite sprite = null, int value = 0, int predicted = 0) { Content = content; Sprite = sprite ?? null; if (Sprite != null) { Sprite.Position = Shape.Position; } Value = value; Predicted = predicted; ValueText.DisplayedString = Value.ToString(); ValueText.Position -= new Vector2f((float)ValueText.DisplayedString.Length / (float)2 * 5, 0); PredictedText.DisplayedString = Predicted.ToString(); PredictedText.Position -= new Vector2f((float)PredictedText.DisplayedString.Length / (float)2 * 5, 0); }
public int updateView(CONTENT ct) { var content = db.CONTENT.Find(ct.content_ID); if (content.view_count == null) { content.view_count = 1; } else { ++content.view_count; } db.SaveChanges(); return(1); }
private CONTENT getContent(String path, string _type) { CONTENT content = new CONTENT(); switch (_type) { case "DOGANDCAT": content = new DOGANDCAT(); break; case "FRIENDS": content = new FRIENDS(); break; case "SPORT": content = new SPORT(); break; case "WORKOUT": content = new WORKOUT(); break; case "FOOD": content = new FOOD(); break; case "BOOK": content = new BOOK(); break; default: Console.WriteLine("WRONG TYPE!!!"); break; } String[] ll = path.Split(new string[] { "\\" }, StringSplitOptions.None); string si = ll.Last(); content.Id = Convert.ToInt32(si); content.dataFolderPath = path; content.parse(); return(content); }
public ActionResult Create(CONTENT model) { if (ModelState.IsValid) { var dao = new ContentDao(); long id = dao.Insert(model); if (id > 0) { SetAlert("Thêm tin tức thành công", "success"); return(RedirectToAction("Index", "Content")); } else { ModelState.AddModelError("", "Thêm tin tức không thành công"); } } SetViewBag(model.ID); return(View("Index")); }
public static bool isAddItem(CONTENT content) { if (forceUpdate) { return(true); } string _type = ""; if (content is WORKOUT) { _type = "WORKOUT"; } if (content is FRIENDS) { _type = "FRIENDS"; } if (content is FOOD) { _type = "FOOD"; } if (content is SPORT) { _type = "SPORT"; } if (content is DOGANDCAT) { _type = "DOGANDCAT"; } int _id = content.Id; string spref = _type + "_" + _id; if (_newContent.ContainsKey(spref)) { return(true); } return(false); }
private void _postAnswer(OOPEZZ_DBEntities db, BotMessageReceivedRequest mess) { char[] spa = { '_' }; String content = mess.postback.payload.Split(spa)[1]; int content_pk = int.Parse(content); ANSWER answer = db.ANSWER.Where(x => x.QUESTION_FK == content_pk).OrderByDescending(x => x.STATUS).First(); String answer_pkseq_contents = answer.ANSWER_TEXT; char[] charac = { '#' }; List <String> pkseqs = answer_pkseq_contents.Split(charac).ToList(); List <CONTENT> contents = new List <CONTENT>(); foreach (String pkseq in pkseqs) { int pk = int.Parse(pkseq); CONTENT ct = db.CONTENT.Where(x => x.PK_SEQ == pk).First(); contents.Add(ct); } _postContentList(db, contents, mess.sender.id); }
public ActionResult Edit(CONTENT content) { if (ModelState.IsValid) { var dao = new ContentDao(); var result = dao.Update(content); if (result) { SetAlert("Sửa tin tức thành công", "success"); return(RedirectToAction("Index", "Content")); } else { ModelState.AddModelError("", "Cập nhật tin tức không thành công"); } } SetViewBag(content.ID); return(View("Index")); }
//берем определенный контент public static CONTENT getContent(String _type, int id) { CONTENT cont = null; switch (_type) { case "DOGANDCAT": return(_DOGANDCAT.FirstOrDefault(o => o.Id == id)); break; case "FRIENDS": return(_FRIENDS.FirstOrDefault(o => o.Id == id)); break; case "SPORT": return(_SPORT.FirstOrDefault(o => o.Id == id)); break; case "WORKOUT": return(_WORKOUT.FirstOrDefault(o => o.Id == id)); break; case "FOOD": return(_FOOD.FirstOrDefault(o => o.Id == id)); break; case "BOOK": return(_BOOK.FirstOrDefault(o => o.Id == id)); break; default: break; } return(cont); }
public List <CONTENT> DataToContent(DataTable dt) { List <CONTENT> list = new List <CONTENT>(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { CONTENT c = new CONTENT { C_CONTENT = dt.Rows[i]["C_CONTENT"].ToString(), C_DATE = dt.Rows[i]["C_DATE"].ToString(), C_ISDEL = dt.Rows[i]["C_ISDEL"].ToString(), C_MAIL = dt.Rows[i]["C_MAIL"].ToString(), C_NAME = dt.Rows[i]["C_NAME"].ToString(), C_TELEPHONE = dt.Rows[i]["C_TELEPHONE"].ToString(), NUM = dt.Rows[i]["NUM"].ToString() }; list.Add(c); } } return(list); }
//* ────________________________________* //* methods ───────────────────────────────-* //* -----------------------------------------------------------------------* /// <summary>初期化処理を実行します。</summary> protected override void initialize() { CGame game = CGame.instance; CSpriteManager sprite = CGame.sprite; CONTENT.setContentManager(game.Content); SpriteFont font = CONTENT.texFont98; for (int i = hudStates.Length; --i >= 0;) { CFont hud = new CFont(font); hud.nextState = hudStates[i]; hud.pos = pos[i]; hud.sprite = sprite; hud.layer = 0; hud.commitNextState(true); hud.alignHorizontal = EAlign.LeftTop; hud.alignVertical = EAlign.LeftTop; new CDrawableGameComponent(game, hud, true); } new CDrawableGameComponent(game, new CEntity(CStateFPSCalculator.instance), true); CGuideWrapper.instance.NotificationPosition = NotificationPosition.Center; }
public HttpResponseMessage Post([FromBody] CONTENT content) { try { using (knowhauEntities entities = new knowhauEntities()) { entities.CONTENTs.Add(content); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, content); message.Headers.Location = new Uri(Request.RequestUri + content.contentmsg.ToString()); return(message); } } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); // Join the list to a single string. var fullErrorMessage = string.Join("; ", errorMessages); // Combine the original exception message with the new one. var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage); // Throw a new DbEntityValidationException with the improved exception message. throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public string GetTitle(int position) { return(TestFragmentAdapter.CONTENT [position % CONTENT.Count()]); }