private void FillUsefulInfoDetails() { if (!string.IsNullOrEmpty(Request.QueryString["Uid"])) { int UsefulInfoId = 0; if (int.TryParse(Request.QueryString["Uid"].ToString(), out UsefulInfoId)) { if (UsefulInfoId > 0) { UsefulInfo UsefulInfo = BLL.GetUsefulInfoById(UsefulInfoId); if (UsefulInfo != null) { dvUsefulInfoDetails.InnerHtml += "<center>"; dvUsefulInfoDetails.InnerHtml += UsefulInfo.Body; dvUsefulInfoDetails.InnerHtml += "</center>"; this.Title = UsefulInfo.Title; lblUsefulInfoTitle.Text = UsefulInfo.Title; lblUsefulInfoPublishDate.Text = UsefulInfo.PublishDate.ToShortDateString(); btnSaveComment.Enabled = true; string metaTags = UsefulInfo.Title; string description = UsefulInfo.Title; AddMetaTagsAndPageDescription(metaTags, description); FillComments(); upnlAddComments.Update(); } } } } }
void btnSaveUsefulInfo_Click(object sender, EventArgs e) { if (IsAddMode) { UsefulInfo UsefulInfo = new UsefulInfo(); UsefulInfo.Title = txtUsefulInfoTitle.Text; UsefulInfo.PublishDate = DateTime.Now; UsefulInfo.Body = UsefulInfoBody.Text; BLL.AddNewUsefulInfo(UsefulInfo); SetAlert(operationMessage); } else { int UsefulInfoId = -1; if (int.TryParse(ddlAllUsefulInfos.SelectedValue, out UsefulInfoId)) { if (UsefulInfoId > 0) { UsefulInfo UsefulInfo = BLL.GetUsefulInfoById(UsefulInfoId); if (UsefulInfo != null) { UsefulInfo.Title = txtUsefulInfoTitle.Text; UsefulInfo.Body = UsefulInfoBody.Text; BLL.UpdateUsefulInfo(UsefulInfo); SetAlert(operationMessage); } } } } FillAllUsefulInfos(); upnlAddUsefulInfo.Update(); }
public void AddInfo() { var info = new UsefulInfo { Description = "Lorem ipsum dolor sit amet", Caption = "Test info", PublishDate = DateTime.Now, Url = "google.com" }; _usefulLinkRepository.Add(info); }
public void Update(string id, UsefulInfo newInfo) { var info = GetInfo(id); if (info == null) { return; } info.Caption = newInfo.Caption; info.Description = newInfo.Description; info.Image = newInfo.Image; info.PublishDate = newInfo.PublishDate; info.Url = newInfo.Url; info.Tags = newInfo.Tags; _mongoRepository.GetRepository <UsefulInfo>().Collection.Save(info); }
void ddlAllUsefulInfos_SelectedIndexChanged(object sender, EventArgs e) { IsAddMode = false; int UsefulInfoId = -1; if (int.TryParse(ddlAllUsefulInfos.SelectedValue, out UsefulInfoId)) { if (UsefulInfoId > 0) { UsefulInfo UsefulInfo = BLL.GetUsefulInfoById(UsefulInfoId); if (UsefulInfo != null) { txtUsefulInfoTitle.Text = UsefulInfo.Title; UsefulInfoBody.Text = UsefulInfo.Body; } } } }
void ibtnDeleteUsefulInfo_Click(object sender, ImageClickEventArgs e) { // try // { List <Comment> UsefulInfoComments = null; string failedUsefulInfo = string.Empty; foreach (GridViewRow row in gvUsefulInfo.Rows) { if (row.RowType == DataControlRowType.DataRow) { HiddenField hdnUsefulInfoId = (HiddenField)row.FindControl("hdnUsefulInfoId"); CheckBox cbSelectedUsefulInfo = (CheckBox)row.FindControl("cbSelect"); if (hdnUsefulInfoId != null && (cbSelectedUsefulInfo != null && cbSelectedUsefulInfo.Checked)) { UsefulInfoComments = BLL.GetCommentsByUsefulInfoId(Convert.ToInt32(hdnUsefulInfoId.Value)); if (UsefulInfoComments == null || UsefulInfoComments.Count <= 0) { BLL.DeleteUsefulInfo(Convert.ToInt32(hdnUsefulInfoId.Value)); SetAlert(operationMessage); } else { UsefulInfo UsefulInfo = BLL.GetUsefulInfoById(Convert.ToInt32(hdnUsefulInfoId.Value)); if (UsefulInfo != null) { failedUsefulInfo += " " + UsefulInfo.Title; } } } } } if (!string.IsNullOrEmpty(failedUsefulInfo)) { SetAlert("لا يمكن حذف المعلومات المفيدة التالية بسبب ارتباطها بتعليقات" + failedUsefulInfo); } //} //catch (Exception ex) //{ // SetAlert("حدث خطأ لا يمكن المتابعة"); //} SearchUsefulInfo(); }
public static void UpdateUsefulInfo(UsefulInfo UsefulInfo) { DAL dal = new DAL(); dal.UpdateUsefulInfo(UsefulInfo); }
public static void AddNewUsefulInfo(UsefulInfo UsefulInfo) { DAL dal = new DAL(); dal.AddNewUsefulInfo(UsefulInfo); }
public void Add(UsefulInfo info) { info.PublishDate = DateTime.Now; base.Insert(info); }
// Some event happens that we want to notify subscribers about void EventHandler(object sender, SomeEventArgs e) { UsefulInfo info = CreateUsefulInfo(e); _observable.OnNext(info); }