//------------------------------------------ #endregion #region --------------Update-------------- public ExecuteCommandStatus Update(ItemsCommentsEntity comments) { using (SqlConnection myConnection = GetSqlConnection()) { SqlCommand myCommand = new SqlCommand("ItemsComments_Update", myConnection); myCommand.CommandType = CommandType.StoredProcedure; // Set the parameters myCommand.Parameters.Add("@CommentID", SqlDbType.Int, 4).Value = comments.CommentID; //myCommand.Parameters.Add("@ItemID", SqlDbType.Int, 4).Value = comments.ItemID; // myCommand.Parameters.Add("@LangID", SqlDbType.Int).Value = (int)comments.LangID; myCommand.Parameters.Add("@SenderName", SqlDbType.NVarChar, 255).Value = comments.SenderName; //myCommand.Parameters.Add("@CountryID", SqlDbType.Int, 4).Value = comments.CountryID; //myCommand.Parameters.Add("@CtryShort", SqlDbType.Char, 2).Value = comments.CtryShort; //myCommand.Parameters.Add("@SendingDate", SqlDbType.DateTime, 8).Value = comments.SendingDate; myCommand.Parameters.Add("@SenderEmail", SqlDbType.NVarChar, 100).Value = comments.SenderEmail; myCommand.Parameters.Add("@CommentTitle", SqlDbType.NVarChar, 200).Value = comments.CommentTitle; myCommand.Parameters.Add("@CommentText", SqlDbType.NVarChar, 1000).Value = comments.CommentText; myCommand.Parameters.Add("@IsActive", SqlDbType.Bit, 1).Value = comments.IsActive; //---------------------------------------------------------------------------------- myCommand.Parameters.Add("@LastUpdateUserName", SqlDbType.NVarChar, 64).Value = (string)comments.LastUpdateUserName; //---------------------------------------------------------------------------------- myCommand.Parameters.Add("@OwnerID", SqlDbType.UniqueIdentifier).Value = comments.OwnerID; //---------------------------------------------------------------------------------- // Execute the command myConnection.Open(); ExecuteCommandStatus status = (ExecuteCommandStatus)myCommand.ExecuteScalar(); myConnection.Close(); return(status); } }
public ItemsCommentsEntity GetObject(int commentID, Guid OwnerID) { ItemsCommentsEntity comments = null; using (SqlConnection myConnection = GetSqlConnection()) { SqlCommand myCommand = new SqlCommand("ItemsComments_GetOneByID", myConnection); myCommand.CommandType = CommandType.StoredProcedure; // Set the parameters myCommand.Parameters.Add("@CommentID", SqlDbType.Int, 4).Value = commentID; //---------------------------------------------------------------------------------- myCommand.Parameters.Add("@OwnerID", SqlDbType.UniqueIdentifier).Value = OwnerID; //---------------------------------------------------------------------------------- // Execute the command myConnection.Open(); using (SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection)) { if (dr.Read()) { comments = PopulateEntity(dr); } dr.Close(); } myConnection.Close(); return(comments); } }
//---------------------------------------------------------- #endregion public static ExecuteCommandStatus Update(ItemsCommentsEntity comments) { //Update user name------------------------------------------ string username = ""; if (HttpContext.Current.User.Identity.IsAuthenticated) { username = HttpContext.Current.User.Identity.Name; comments.LastUpdateUserName = username; } //---------------------------------------------------------- return(ItemsCommentsSqlDataPrvider.Instance.Update(comments)); }
//------------------------------------------ #endregion #region --------------Create-------------- /// <summary> /// Converts the Comments object properties to SQL paramters and executes the create Comments procedure /// and updates the Comments object with the SQL data by reference. /// <example>[Example]bool status=ItemsCommentsSqlDataPrvider.Instance.Create(comments);.</example> /// </summary> /// <param name="comments">The Comments object.</param> /// <returns>The status of create query.</returns> public ExecuteCommandStatus Create(ItemsCommentsEntity comments) { using (SqlConnection myConnection = GetSqlConnection()) { SqlCommand myCommand = new SqlCommand("ItemsComments_Create", myConnection); myCommand.CommandType = CommandType.StoredProcedure; // Set the parameters myCommand.Parameters.Add("@CommentID", SqlDbType.Int, 4).Direction = ParameterDirection.Output; myCommand.Parameters.Add("@ItemID", SqlDbType.Int, 4).Value = comments.ItemID; myCommand.Parameters.Add("@LangID", SqlDbType.Int).Value = (int)comments.LangID; myCommand.Parameters.Add("@SenderName", SqlDbType.NVarChar, 255).Value = comments.SenderName; myCommand.Parameters.Add("@CountryID", SqlDbType.Int, 4).Value = comments.CountryID; myCommand.Parameters.Add("@CtryShort", SqlDbType.Char, 2).Value = comments.CtryShort; myCommand.Parameters.Add("@SendingDate", SqlDbType.DateTime, 8).Value = comments.SendingDate; myCommand.Parameters.Add("@SenderEmail", SqlDbType.NVarChar, 100).Value = comments.SenderEmail; myCommand.Parameters.Add("@CommentTitle", SqlDbType.NVarChar, 200).Value = comments.CommentTitle; myCommand.Parameters.Add("@CommentText", SqlDbType.NVarChar, 1000).Value = comments.CommentText; myCommand.Parameters.Add("@IsActive", SqlDbType.Bit, 1).Value = comments.IsActive; //---------------------------------------------------------------------------------- myCommand.Parameters.Add("@InsertUserName", SqlDbType.NVarChar, 64).Value = (string)comments.InsertUserName; //---------------------------------------------------------------------------------- myCommand.Parameters.Add("@ModuleTypeID", SqlDbType.Int).Value = comments.ModuleTypeID; myCommand.Parameters.Add("@BaseModuleType", SqlDbType.Int).Value = (int)comments.BaseModuleType; //---------------------------------------------------------------------------------- myCommand.Parameters.Add("@OwnerID", SqlDbType.UniqueIdentifier).Value = comments.OwnerID; //---------------------------------------------------------------------------------- // Execute the command myConnection.Open(); ExecuteCommandStatus status = (ExecuteCommandStatus)myCommand.ExecuteScalar(); if (status == ExecuteCommandStatus.Done) { //Get ID value from database and set it in object comments.CommentID = (int)myCommand.Parameters["@CommentID"].Value; } myConnection.Close(); return(status); } }
//------------------------------------------------------- public void InitializeAllOpjects() { #region Initial lItem InitialItem = new ItemsEntity(); //InitialItem.CategoryID = xxxx; //InitialItem.ItemID //InitialItem.CategoryID //InitialItem.ModuleTypeID = moduleType; //InitialItem.PhotoExtension InitialItem.Url = Url; InitialItem.Email = Email; InitialItem.MailBox = MailBox; InitialItem.ZipCode = ZipCode; InitialItem.Tels = Tels; InitialItem.Fax = Fax; InitialItem.Mobile = Mobile; InitialItem.ItemDate = ItemDate; InitialItem.ItemEndDate = ItemEndDate; InitialItem.IsAvailable = IsAvailable; InitialItem.YoutubeCode = YoutubeCode; InitialItem.GoogleLatitude = GoogleLatitude; InitialItem.GoogleLongitude = GoogleLongitude; InitialItem.Price = Price; /* * InitialItem.SenderName * InitialItem.SenderEMail * InitialItem.SenderCountryID * InitialItem.Reply * InitialItem.ReplyDate * InitialItem.IsSeen * InitialItem.IsReplied * InitialItem.IsReviewed * InitialItem.ToUserID * InitialItem.ActivatedBy * InitialItem.ReviewedBy * InitialItem.OwnerID */ InitialItem.Type = Type; #endregion #region InitialItemArDetails InitialItemArDetails = new ItemsDetailsEntity(); //InitialItemArDetails.ItemID = InitialItem.ItemID; InitialItemArDetails.LangID = Languages.Ar; InitialItemArDetails.Title = ArItemTitle; InitialItemArDetails.ShortDescription = ArItemShortDescrpyion; InitialItemArDetails.Description = ArItemDetails; InitialItemArDetails.KeyWords = ArItemSeoKeyWords; InitialItemArDetails.Address = ArItemAddress; InitialItemArDetails.AuthorName = ArItemAuthorName; #endregion #region InitialItemArDetails InitialItemEnDetails = new ItemsDetailsEntity(); //InitialItemEnDetails.ItemID = InitialItem.ItemID; InitialItemEnDetails.LangID = Languages.En; InitialItemEnDetails.Title = EnItemTitle; InitialItemEnDetails.ShortDescription = EnItemShortDescrpyion; InitialItemEnDetails.Description = EnItemDetails; InitialItemEnDetails.KeyWords = EnItemSeoKeyWords; InitialItemEnDetails.Address = EnItemAddress; InitialItemEnDetails.AuthorName = EnItemAuthorName; #endregion #region Initial Category InitialCategory = new ItemCategoriesEntity(); //InitialCategory.CategoryID; //InitialCategory.PhotoExtension; //InitialCategory.ModuleTypeID; //InitialCategory.ParentID; //InitialCategory.TypeID =Type; InitialCategory.ItemDate = ItemDate; InitialCategory.IsAvailable = IsAvailable; InitialCategory.YoutubeCode = YoutubeCode; InitialCategory.GoogleLatitude = GoogleLatitude; InitialCategory.GoogleLongitude = GoogleLongitude; #endregion #region Initial Category Parent InitialCategoryParent = new ItemCategoriesEntity(); //InitialCategoryParent.CategoryID; //InitialCategoryParent.PhotoExtension; //InitialCategoryParent.ModuleTypeID; //InitialCategoryParent.ParentID; //InitialCategoryParent.TypeID =Type; InitialCategoryParent.ItemDate = ItemDate; InitialCategoryParent.IsAvailable = IsAvailable; InitialCategoryParent.YoutubeCode = YoutubeCode; InitialCategoryParent.GoogleLatitude = GoogleLatitude; InitialCategoryParent.GoogleLongitude = GoogleLongitude; #endregion #region InitialCategoryArDetails InitialCategoryArDetails = new ItemCategoriesDetailsEntity(); //InitialCategoryArDetails.CategoryID = InitialCategory.CategoryID; InitialCategoryArDetails.LangID = Languages.Ar; InitialCategoryArDetails.Title = ArCategoryTitle; InitialCategoryArDetails.ShortDescription = ArItemShortDescrpyion; InitialCategoryArDetails.Description = ArItemDetails; InitialCategoryArDetails.KeyWords = ArItemSeoKeyWords; #endregion #region InitialCategoryEnDetails InitialCategoryEnDetails = new ItemCategoriesDetailsEntity(); //InitialCategoryEnDetails.CategoryID = InitialCategory.CategoryID; InitialCategoryEnDetails.LangID = Languages.En; InitialCategoryEnDetails.Title = EnCategoryTitle; InitialCategoryEnDetails.ShortDescription = EnItemShortDescrpyion; InitialCategoryEnDetails.Description = EnItemDetails; InitialCategoryEnDetails.KeyWords = EnItemSeoKeyWords; #endregion #region InitialArComment InitialArComment = new ItemsCommentsEntity(); //InitialArComment.CommentID //InitialArComment.ItemID InitialArComment.LangID = Languages.Ar; //InitialArComment.ModuleTypeID //InitialArComment.BaseModuleType InitialArComment.SenderName = ArSenderName; InitialArComment.CountryID = SenderCountryID; //InitialArComment.CtryShort InitialArComment.SendingDate = DateTime.Now; InitialArComment.SenderEmail = SenderEMail; InitialArComment.CommentTitle = ArCommentTitle; InitialArComment.CommentText = ArItemDetails; InitialArComment.IsActive = IsAvailable; InitialArComment.IsSeen = IsSeen; #endregion #region InitialEnComment InitialEnComment = new ItemsCommentsEntity(); //InitialEnComment.CommentID //InitialEnComment.ItemID InitialEnComment.LangID = Languages.En; //InitialEnComment.ModuleTypeID //InitialEnComment.BaseModuleType InitialEnComment.SenderName = EnSenderName; InitialEnComment.CountryID = SenderCountryID; //InitialEnComment.CtryShort InitialEnComment.SendingDate = DateTime.Now; InitialEnComment.SenderEmail = SenderEMail; InitialEnComment.CommentTitle = EnCommentTitle; InitialEnComment.CommentText = EnItemDetails; InitialArComment.IsActive = IsAvailable; InitialArComment.IsSeen = IsSeen; #endregion #region InitialArMessages InitialArMessages = new MessagesEntity(); //InitialArMessages.MessageID=; //InitialArMessages.ModuleTypeID //InitialArMessages.CategoryID ; InitialArMessages.Name = ArSenderName; InitialArMessages.Mobile = Mobile; InitialArMessages.EMail = Email; InitialArMessages.NationalityID = SiteSettings.Admininstration_SiteDefaultCountryID; InitialArMessages.CountryID = SiteSettings.Admininstration_SiteDefaultCountryID; InitialArMessages.Address = ArItemAddress; InitialArMessages.JobTel = JobTel; InitialArMessages.Type = Type; InitialArMessages.Title = ArMessageTitle; InitialArMessages.Details = ArItemDetails; InitialArMessages.ShortDescription = ArItemShortDescrpyion; InitialArMessages.Reply = ArItemDetails; InitialArMessages.ReplyDate = DateTime.Now; InitialArMessages.IsAvailable = IsAvailable; InitialArMessages.IsSeen = IsSeen; InitialArMessages.IsReplied = IsReplied; InitialArMessages.LangID = Languages.Ar; InitialArMessages.Gender = Gender.Male; InitialArMessages.BirthDate = BirthDate; InitialArMessages.CityID = CityID; InitialArMessages.UserCityName = UserCityNameAr; InitialArMessages.Tel = Tels; InitialArMessages.Fax = Fax; InitialArMessages.MailBox = MailBox; InitialArMessages.ZipCode = ZipCode; InitialArMessages.JobID = JobID; InitialArMessages.JobText = JobTextAr; InitialArMessages.Company = CompanyAr; InitialArMessages.ActivitiesID = ActivitiesID; InitialArMessages.Url = Url; //InitialArMessages.PhotoExtension InitialArMessages.SocialStatus = SocialStatus; InitialArMessages.EducationLevel = EducationLevel; InitialArMessages.EmpNo = EmpNo; InitialArMessages.HasSmsService = HasSmsService; InitialArMessages.HasEmailService = HasEmailService; //InitialArMessages.Notes1 //InitialArMessages.Notes2 InitialArMessages.AgeRang = AgeRang; InitialArMessages.ItemDate = ItemDate; InitialArMessages.YoutubeCode = YoutubeCode; InitialArMessages.GoogleLatitude = GoogleLatitude.ToString(); InitialArMessages.GoogleLongitude = GoogleLongitude.ToString(); InitialArMessages.Price = Price; InitialArMessages.KeyWords = ArItemSeoKeyWords; InitialArMessages.LastModification = DateTime.Now; #endregion #region InitialEnMessages InitialEnMessages = new MessagesEntity(); //InitialEnMessages.MessageID=; //InitialEnMessages.ModuleTypeID //InitialEnMessages.CategoryID ; InitialEnMessages.Name = EnSenderName; InitialEnMessages.Mobile = Mobile; InitialEnMessages.EMail = Email; InitialEnMessages.NationalityID = SiteSettings.Admininstration_SiteDefaultCountryID; InitialEnMessages.CountryID = SiteSettings.Admininstration_SiteDefaultCountryID; InitialEnMessages.Address = EnItemAddress; InitialEnMessages.JobTel = JobTel; InitialEnMessages.Type = Type; InitialEnMessages.Title = EnMessageTitle; InitialEnMessages.Details = EnItemDetails; InitialEnMessages.ShortDescription = EnItemShortDescrpyion; InitialEnMessages.Reply = EnItemDetails; InitialEnMessages.ReplyDate = DateTime.Now; InitialEnMessages.IsAvailable = IsAvailable; InitialEnMessages.IsSeen = IsSeen; InitialEnMessages.IsReplied = IsReplied; InitialEnMessages.LangID = Languages.En; InitialEnMessages.Gender = Gender.Male; InitialEnMessages.BirthDate = BirthDate; InitialEnMessages.CityID = CityID; InitialEnMessages.UserCityName = UserCityNameEn; InitialEnMessages.Tel = Tels; InitialEnMessages.Fax = Fax; InitialEnMessages.MailBox = MailBox; InitialEnMessages.ZipCode = ZipCode; InitialEnMessages.JobID = JobID; InitialEnMessages.JobText = JobTextEn; InitialEnMessages.Company = CompanyEn; InitialEnMessages.ActivitiesID = ActivitiesID; InitialEnMessages.Url = Url; //InitialEnMessages.PhotoExtension InitialEnMessages.SocialStatus = SocialStatus; InitialEnMessages.EducationLevel = EducationLevel; InitialEnMessages.EmpNo = EmpNo; InitialEnMessages.HasSmsService = HasSmsService; InitialEnMessages.HasEmailService = HasEmailService; //InitialEnMessages.Notes1 //InitialEnMessages.Notes2 InitialEnMessages.AgeRang = AgeRang; InitialEnMessages.ItemDate = ItemDate; InitialEnMessages.YoutubeCode = YoutubeCode; InitialEnMessages.GoogleLatitude = GoogleLatitude.ToString(); InitialEnMessages.GoogleLongitude = GoogleLongitude.ToString(); InitialEnMessages.Price = Price; InitialEnMessages.KeyWords = EnItemSeoKeyWords; InitialEnMessages.LastModification = DateTime.Now; #endregion }
//------------------------------------------ #endregion #region --------------PopulateEntity-------------- private ItemsCommentsEntity PopulateEntity(IDataReader reader) { //Create a new Comments object ItemsCommentsEntity comments = new ItemsCommentsEntity(); //Fill the object with data //CommentID if (reader["CommentID"] != DBNull.Value) { comments.CommentID = (int)reader["CommentID"]; } //ItemID if (reader["ItemID"] != DBNull.Value) { comments.ItemID = (int)reader["ItemID"]; } //LangID if (reader["LangID"] != DBNull.Value) { comments.LangID = (Languages)reader["LangID"]; } //ModuleTypeID if (reader["ModuleTypeID"] != DBNull.Value) { comments.ModuleTypeID = (int)reader["ModuleTypeID"]; } //SenderName if (reader["SenderName"] != DBNull.Value) { comments.SenderName = (string)reader["SenderName"]; } //CountryID if (reader["CountryID"] != DBNull.Value) { comments.CountryID = (int)reader["CountryID"]; } //CtryShort if (reader["CtryShort"] != DBNull.Value) { comments.CtryShort = (string)reader["CtryShort"]; } //SendingDate if (reader["SendingDate"] != DBNull.Value) { comments.SendingDate = (DateTime)reader["SendingDate"]; } //SenderEmail if (reader["SenderEmail"] != DBNull.Value) { comments.SenderEmail = (string)reader["SenderEmail"]; } //CommentTitle if (reader["CommentTitle"] != DBNull.Value) { comments.CommentTitle = (string)reader["CommentTitle"]; } //CommentText if (reader["CommentText"] != DBNull.Value) { comments.CommentText = (string)reader["CommentText"]; } //IsActive if (reader["IsActive"] != DBNull.Value) { comments.IsActive = (bool)reader["IsActive"]; } //IsSeen if (reader["IsSeen"] != DBNull.Value) { comments.IsSeen = (bool)reader["IsSeen"]; } //BadAlertsCount if (reader["BadAlertsCount"] != DBNull.Value) { comments.BadAlertsCount = (int)reader["BadAlertsCount"]; } //------------------------------------------------------------------ //InsertUserName if (reader["InsertUserName"] != DBNull.Value) { comments.InsertUserName = (string)reader["InsertUserName"]; } //------------------------------------------------------------------ //LastUpdateUserName if (reader["LastUpdateUserName"] != DBNull.Value) { comments.LastUpdateUserName = (string)reader["LastUpdateUserName"]; } //------------------------------------------------------------------ //Return the populated object return(comments); }