/// <summary> /// This method will delete the Topic from the More about section /// </summary> /// <param name="objStory">stories object which contain the Section id and Userbioagraphy ID /// of the topic which topic user wants to delete /// </param> public void DeleteTopic(Stories objStory) { try { if (objStory != null) { object[] objStoryParam = { objStory.MoreAboutSection[0].SectionId, objStory.MoreAboutSection[0].UserBiographyId }; Delete("usp_DeleteTopic", objStoryParam); } } catch (System.Data.SqlClient.SqlException sqlEx) { if (sqlEx.Number >= 50000) { Errors objError = new Errors(); objError.ErrorMessage = sqlEx.Message; objStory.CustomError = objError; } } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will call the Story Mananger class method to Delete the Topic from the More about section /// </summary> /// <param name="objStory">stories object which contain the Section id and Userbioagraphy ID /// of the topic which topic user wants to delete /// </param> public void DeleteTopic(Stories objStory) { try { FacadeManager.StoryManager.DeleteTopic(objStory); } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will call the Story Resource access class method to Delete the Topic from the /// More about section and also send a email to all admin user /// </summary> /// <param name="objStory">stories object which contain the Section id and Userbioagraphy ID /// of the topic which topic user wants to delete /// </param> public void DeleteTopic(Stories objStory) { try { StoryResource objStoryRes = new StoryResource(); objStoryRes.DeleteTopic(objStory); } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will call the Story Resource access class method to get the Tribute Detail, /// Story, and List of topic in More About section. and calcumate the age of the User. /// </summary> /// /// <param name="objStory"> This is the stories object which contain the Tribute ID to get ///the story for that tribute and user ID to get that user is admin or not for that tribute /// </param> /// /// <returns> This method will return the story object /// </returns> public Stories GetStoryDetail(Stories objStoryParam) { try { StoryResource objStoryRes = new StoryResource(); Stories objStory = objStoryRes.GetStoryDetail(objStoryParam); if (objStory.TributeType == "Memorial") { objStory.Age = CalculateAge( objStory.Date1, objStory.Date2 ); } return objStory; } catch (Exception ex) { throw ex; } }
public Stories ClaculateAge(Stories objStory) { Stories objStoryDetail = new Stories (); try { if (objStory != null) { object[] objStoryParam = { objStory.Date1, objStory.Date2,objStory.Age,0 ,0}; if (objStoryParam != null) { DataSet dsStory = new DataSet(); dsStory = GetDataSet("uspCalculateAge", objStoryParam); objStoryDetail.Age = dsStory.Tables[0].Rows[0][0].ToString(); //int.Parse (dsStory.Tables[0].Rows[0][0].ToString()); } } } catch (System.Data.SqlClient.SqlException sqlEx) { if (sqlEx.Number >= 50000) { Errors objError = new Errors(); objError.ErrorMessage = sqlEx.Message; objStory.CustomError = objError; } } catch (Exception ex) { throw ex; } return objStoryDetail; }
/// <summary> /// This method will update the story in database /// </summary> /// /// <param name="objStory">A Stories object which contain the stories detail which have to update</param> private void UpdateStory(Stories objStory) { try { // sets the name of the parameters string[] strParam = { StoryMoreAbout.StoriesMoreAboutEnum.SectionId.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.UserBiographyId.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.SecondaryTitle.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.SectionAnswer.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.ModifiedBy.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.ModifiedDate.ToString() }; // sets the types of parameters DbType[] enumType = { DbType.Int64, DbType.Int64, DbType.String, DbType.String, DbType.Int64, DbType.DateTime, }; // sets the value of the paramter object[] objStoryParam = { objStory.MoreAboutSection[0].SectionId, objStory.MoreAboutSection[0].UserBiographyId, objStory.MoreAboutSection[0].SecondaryTitle, objStory.MoreAboutSection[0].SectionAnswer, objStory.MoreAboutSection[0].ModifiedBy, objStory.MoreAboutSection[0].ModifiedDate }; // call stored procedure to update the story UpdateRecord("usp_UpdateStory", strParam, enumType, objStoryParam); } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will populate the stories object from the dataset /// </summary> /// <param name="dsStory">A Dataset which contain story data</param> /// <returns>This method will return the Stories object populated with the story detail</returns> private Stories PopulateStoryObject(DataSet dsStory) { try { Stories objStory = new Stories(); // Get the User role for the tribute if (dsStory.Tables.Count > 0) { if (dsStory.Tables[0].Rows.Count > 0) { DataRow drAdmin = dsStory.Tables[0].Rows[0]; if (int.Parse(drAdmin["IsAdmin"].ToString()) == 0) { objStory.IsAdmin = false; } else { objStory.IsAdmin = true; } } } // Get the Tribute Detail if (dsStory.Tables.Count > 1) { if (dsStory.Tables[1].Rows.Count > 0) { DataRow drStory = dsStory.Tables[1].Rows[0]; objStory.TributeName = drStory["TributeName"].ToString(); objStory.TributeType = drStory["TributeType"].ToString(); objStory.TributeImage = drStory["TributeImage"].ToString(); if ( (drStory["Date1"] != null) && (drStory["Date1"].ToString() != "")) { objStory.Date1 = DateTime.Parse(drStory["Date1"].ToString()); } if ( (drStory["Date2"] != null) && (drStory["Date2"].ToString() != "")) { objStory.Date2 = DateTime.Parse(drStory["Date2"].ToString()); } objStory.PostMessage = drStory["PostMessage"].ToString(); objStory.MessageWithoutHtml = drStory["MessageWithoutHtml"].ToString(); objStory.City = drStory["City"].ToString(); if ((drStory["State"] != null) && (drStory["State"].ToString() != "")) { objStory.State = int.Parse(drStory["State"].ToString()); } if ((drStory["Country"] != null) && (drStory["Country"].ToString() != "")) { objStory.Country = int.Parse(drStory["Country"].ToString()); } objStory.StateName = drStory["StateName"].ToString(); objStory.CountryName = drStory["CountryName"].ToString(); } } // Get the Story and More About section List<StoryMoreAbout> objMoreAboutList = new List<StoryMoreAbout>(); if (dsStory.Tables.Count > 2) { if (dsStory.Tables[2].Rows.Count > 0) { foreach (DataRow drStory in dsStory.Tables[2].Rows) { objMoreAboutList.Add(GetMoreAboutSection(drStory)); } objStory.MoreAboutSection = objMoreAboutList; } } return objStory; } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will Insert the story in database /// </summary> /// /// <param name="objStory">A Stories object which contain the stories detail which have to add /// </param> private void InsertStory(Stories objStory) { try { // sets the name of the parameters string[] strParam = { Stories.StoriesEnum.UserId.ToString(), Stories.StoriesEnum.TributeId.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.PrimaryTitle.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.SecondaryTitle.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.SectionAnswer.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.CreatedBy.ToString(), StoryMoreAbout.StoriesMoreAboutEnum.CreatedDate.ToString() }; // sets the types of parameters DbType[] enumType = { DbType.Int64, DbType.Int64, DbType.String, DbType.String, DbType.String, DbType.Int64, DbType.DateTime, }; // sets the value of the paramter object[] objValue = { objStory.UserId, objStory.TributeId, objStory.MoreAboutSection[0].PrimaryTitle, objStory.MoreAboutSection[0].SecondaryTitle, objStory.MoreAboutSection[0].SectionAnswer, objStory.MoreAboutSection[0].CreatedBy, objStory.MoreAboutSection[0].CreatedDate }; // call stored procedure to save the story InsertRecord("usp_InsertStory", strParam, enumType, objValue); } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will call the Story Resource access class method to update the tribute detail /// and also send a email to all admin user /// </summary> /// /// <param name="objTribute">Stories object which contain the Tribute detail which user want to update /// </param> public void UpdateTributeDetail(Stories objStory) { try { StoryResource objStoryRes = new StoryResource(); objStoryRes.UpdateTributeDetail(objStory); StateManager objStateManager = StateManager.Instance; SessionValue objSessionValue = (SessionValue)objStateManager.Get(PortalEnums.SessionValueEnum.objSessionvalue.ToString(), StateManager.State.Session); StateManager objStateManager_ = StateManager.Instance; Tributes objTribute = (Tributes)objStateManager_.Get(PortalEnums.SessionValueEnum.TributeSession.ToString(), StateManager.State.Session); TributesPortal.Utilities.StateManager stateManager = TributesPortal.Utilities.StateManager.Instance; string Servername = (string)stateManager.Get("SERVERNAME", TributesPortal.Utilities.StateManager.State.Session); string UserName = objSessionValue.FirstName == string.Empty ? objSessionValue.UserName : (objSessionValue.FirstName + " " + objSessionValue.LastName); string EmailSubject = UserName + " updated a story on Your Tribute..."; StringBuilder obhstrb = new StringBuilder(); obhstrb.Append("<font style='font-size: 12px; font-family:Lucida Sans;'><p>" + UserName + " updated the story in the " + objTribute.TributeName + " " + objTribute.TypeDescription + " Tribute.</p>"); obhstrb.Append("<p>To read the story, follow the link below:<br/>"); string strLink = "http://" + objTribute.TypeDescription.Replace("New Baby", "newbaby").ToLower() + "." + WebConfig.TopLevelDomain + "/" + objTribute.TributeUrl + "/story.aspx"; obhstrb.Append("<a href='" + strLink + "' >" + strLink + "</a><p>"); obhstrb.Append("<p>---<br/>"); obhstrb.Append("Your Tribute Team</p></font>"); SendEmail(objStory.TributeId, EmailSubject, obhstrb.ToString()); } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will call the Story Mananger class method to update the tribute detail /// </summary> /// /// <param name="objTribute">Stories object which contain the Tribute detail which user want to update /// </param> public void UpdateTributeDetail(Stories objTribute) { try { FacadeManager.StoryManager.UpdateTributeDetail(objTribute); } catch (Exception ex) { throw ex; } }
//UpdateObituaryDetail public void UpdateObituaryDetail(Stories objsTribute) { try { if (objsTribute != null) { //sets the parameters string[] strParam = { Stories.ObituaryMaintainState.TributeId.ToString(), Stories.ObituaryMaintainState.PostMessage.ToString(), Stories.ObituaryMaintainState.MessageWithoutHtml.ToString(), Stories.ObituaryMaintainState.MessageAddedModifiedBy.ToString(), }; //sets the types of parameters DbType[] enumType = { DbType.Int64, DbType.String, DbType.String, DbType.Int64, }; object[] objTributeVal = { objsTribute.TributeId, objsTribute.PostMessage, objsTribute.MessageWithoutHtml, objsTribute.MessageAddedModifiedBy }; UpdateRecordMinusIovs("usp_UpdateObituaryDetail", strParam, enumType, objTributeVal); } } catch (System.Data.SqlClient.SqlException sqlEx) { if (sqlEx.Number >= 50000) { Errors objError = new Errors(); objError.ErrorMessage = sqlEx.Message; objsTribute.CustomError = objError; } } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will get the Tribute Detail, Story, and List of topic in More About /// </summary> /// /// <param name="objStory"> This is the stories object which contain the Tribute ID to get ///the story for that tribute and user ID to get that user is admin or not for that tribute /// </param> /// /// <returns> This method will return the story object which is populated with the /// Tribute Detail, story and more about for the Tribute /// </returns> public Stories GetStoryDetail(Stories objStory) { Stories objStoryDetail = null; try { if (objStory != null) { object[] objStoryParam = { objStory.TributeId, objStory.UserId }; if (objStoryParam != null) { DataSet dsStory = new DataSet(); dsStory = GetDataSet("usp_GetStory", objStoryParam); objStoryDetail = PopulateStoryObject(dsStory); } } } catch (System.Data.SqlClient.SqlException sqlEx) { if (sqlEx.Number >= 50000) { Errors objError = new Errors(); objError.ErrorMessage = sqlEx.Message; objStory.CustomError = objError; } } catch (Exception ex) { throw ex; } return objStoryDetail; }
/// <summary> /// This method will return the location by combining the city, state and country /// </summary> /// <param name="objStory">A Story object which contain teh city, state and country</param> /// <returns>Return the location</returns> private string GetLocation(Stories objStory) { string location = ""; try { if (objStory.City != "") { location = objStory.City; } if (objStory.StateName != "") { if (location != "") { location += ", "; } location += objStory.StateName; } if (location != "") { location += ", "; } location += objStory.CountryName; } catch (Exception ex) { throw ex; } return location; }
/// <summary> /// This method will calculate the age of the user if tribute is memorial /// </summary> /// <param name="Date1">This is datetime object which is date of Birth</param> /// <param name="Date2">This is datetime object which is date of Death</param> /// <returns>This will return the </returns> private string CalculateAge(Nullable<DateTime> Date1, Nullable<DateTime> Date2) { try { if ((Date1 != null) && (Date1.ToString() != "") && (Date2 != null) && (Date2.ToString() != "")) { Stories story = new Stories(); story.Date1 = Date1; story.Date2 = Date2; TributesPortal.ResourceAccess.StoryResource sr=new StoryResource (); story =sr.ClaculateAge(story); if (story.Age != "0") return story.Age; else return "<1"; } else { return "0"; } } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will call the Story Mananger class method to get the Tribute Detail, Story, /// and List of topic in More About section. and calcumate the age of the User. /// </summary> /// /// <param name="objStory"> This is the stories object which contain the Tribute ID to get ///the story for that tribute and user ID to get that user is admin or not for that tribute /// </param> /// /// <returns> This method will return the story object /// </returns> public Stories GetStoryDetail(Stories objStory) { try { return FacadeManager.StoryManager.GetStoryDetail(objStory); } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will call the Story Mananger class method to Add and update the Story detail /// and also add new topic in the more about section /// </summary> /// /// <param name="objStory">Stories object which contain the story detail which user want to update /// </param> public void UpdateStoryDetail(Stories objStory) { try { FacadeManager.StoryManager.UpdateStoryDetail(objStory); } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will Add and update the Story detail and also add new topic in the more about section /// </summary> /// /// <param name="objStory">Stories object which contain the story detail which user want to update /// </param> public void UpdateStoryDetail(Stories objStory) { try { if (objStory != null) { if (objStory.Operation == "Add") { InsertStory(objStory); } else if (objStory.Operation == "Update") { UpdateStory(objStory); } } } catch (System.Data.SqlClient.SqlException sqlEx) { if (sqlEx.Number >= 50000) { Errors objError = new Errors(); objError.ErrorMessage = sqlEx.Message; objStory.CustomError = objError; } } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will update the tribute detail /// </summary> /// /// <param name="objTribute">Stories object which contain the Tribute detail which user want to update /// </param> public void UpdateTributeDetail(Stories objTribute) { try { if (objTribute != null) { //sets the parameters string[] strParam = { Stories.StoriesEnum.TributeId.ToString(), Stories.StoriesEnum.TributeName.ToString(), Stories.StoriesEnum.TributeImage.ToString(), Stories.StoriesEnum.City.ToString(), Stories.StoriesEnum.State.ToString(), Stories.StoriesEnum.Country.ToString(), Stories.StoriesEnum.Date1.ToString(), Stories.StoriesEnum.Date2.ToString(), Stories.StoriesEnum.ModifiedBy.ToString(), Stories.StoriesEnum.ModifiedDate.ToString(), }; //sets the types of parameters DbType[] enumType = { DbType.Int64, DbType.String, DbType.String, DbType.String, DbType.Int64, DbType.Int64, DbType.DateTime, DbType.DateTime, DbType.Int64, DbType.DateTime, }; object[] objTributeVal = { objTribute.TributeId, objTribute.TributeName, objTribute.TributeImage, objTribute.City, objTribute.State, objTribute.Country, objTribute.Date1, objTribute.Date2, objTribute.ModifiedBy, objTribute.ModifiedDate }; UpdateRecord("usp_UpdateTributeDetail", strParam, enumType, objTributeVal); } } catch (System.Data.SqlClient.SqlException sqlEx) { if (sqlEx.Number >= 50000) { Errors objError = new Errors(); objError.ErrorMessage = sqlEx.Message; objTribute.CustomError = objError; } } catch (Exception ex) { throw ex; } }
public void UpdateObituaryDetail(Stories objStory) { try { StoryResource objStoryRes = new StoryResource(); objStoryRes.UpdateObituaryDetail(objStory); } catch (Exception ex) { throw ex; } }