//INSERT- UPDATE - DELETE public int Insert(string UserId, int TypeId, int ParentId, string Name, string Photo, string Description, string Status) { string Alias = module_obj.createTags(Name); using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; System.Nullable <Int32> ListOrder = (from u in dbContext.Media_Types select u.TypeId).DefaultIfEmpty(0).Max() + 1; Media_Topics topic_obj = new Media_Topics(); topic_obj.TypeId = TypeId; topic_obj.Name = Name; topic_obj.Alias = Alias; topic_obj.ParentId = ParentId; topic_obj.ListOrder = (ListOrder == null ? 1 : ListOrder); topic_obj.Photo = Photo; topic_obj.Description = Description; topic_obj.IPLog = IP; topic_obj.CreatedByUserId = new Guid(UserId); topic_obj.CreatedOnDate = System.DateTime.Now; topic_obj.Status = Status; dbContext.AddToMedia_Topics(topic_obj); int i = dbContext.SaveChanges(); return(i); } }
public int Insert(string userid, int portalid, string culturecode, string code, string title, string headline, string abstract_info, string frontimage, string mainimage, string maintext, string source, string navigateurl, string status) { /*** PostedDate ******************************************************************************/ //System.Globalization.CultureInfo customCulture = new System.Globalization.CultureInfo("en-US"); //customCulture.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy"; //customCulture.DateTimeFormat.ShortTimePattern = "HH:mm:ss"; //System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; //System.Threading.Thread.CurrentThread.CurrentUICulture = customCulture; //string PostedDate = System.DateTime.Now.ToString("G"); /*********************************************************************************************/ string alias = ModuleClass.convertTitle2Link(headline); maintext = module_obj.UTF8_Encode(maintext); string tags = module_obj.createTags(headline); SqlCommand cmd = new SqlCommand("[Articles].[sp_Articles_Insert]", con) { CommandType = CommandType.StoredProcedure, CommandTimeout = Settings.CommandTimeout }; cmd.Parameters.AddWithValue("@userid", userid); cmd.Parameters.AddWithValue("@ip", ip); cmd.Parameters.AddWithValue("@portalid", portalid); cmd.Parameters.AddWithValue("@culturecode", culturecode); cmd.Parameters.AddWithValue("@code", code); cmd.Parameters.AddWithValue("@title", title); cmd.Parameters.AddWithValue("@headline", headline); cmd.Parameters.AddWithValue("@alias", alias); cmd.Parameters.AddWithValue("@abstract", abstract_info); cmd.Parameters.AddWithValue("@frontimage", frontimage); cmd.Parameters.AddWithValue("@mainimage", mainimage); cmd.Parameters.AddWithValue("@maintext", maintext); cmd.Parameters.AddWithValue("@tags", tags); cmd.Parameters.AddWithValue("@source", source); cmd.Parameters.AddWithValue("@navigateurl", navigateurl); cmd.Parameters.AddWithValue("@status", status); cmd.Parameters.Add(new SqlParameter("@o_return", SqlDbType.Int) { Direction = ParameterDirection.Output }); con.Open(); int i = cmd.ExecuteNonQuery(); int retunvalue = (int)cmd.Parameters["@o_return"].Value; con.Close(); return(retunvalue); }
//INSERT- UPDATE - DELETE public int Insert(string userid, int vendorid, int typeid, int topicid, int playlistid, int albumid, int artistid, int composerid, string filename, string fileurl, string title, string description, int autostart, int medialoop, string dimension, string source, string photo, string thumbnail, string status) { string alias = module_obj.createTags(title); SqlCommand cmd = new SqlCommand("[Media].[Files_Insert]", con) { CommandType = CommandType.StoredProcedure, CommandTimeout = Settings.CommandTimeout }; cmd.Parameters.AddWithValue("@userid", userid); cmd.Parameters.AddWithValue("@ip", ip); cmd.Parameters.AddWithValue("@vendorid", vendorid); cmd.Parameters.AddWithValue("@typeid", typeid); cmd.Parameters.AddWithValue("@topicid", topicid); cmd.Parameters.AddWithValue("@playlistid", playlistid); cmd.Parameters.AddWithValue("@albumid", albumid); cmd.Parameters.AddWithValue("@artistid", artistid); cmd.Parameters.AddWithValue("@composerid", composerid); cmd.Parameters.AddWithValue("@filename", filename); cmd.Parameters.AddWithValue("@alias", alias); cmd.Parameters.AddWithValue("@fileurl", fileurl); cmd.Parameters.AddWithValue("@title", title); cmd.Parameters.AddWithValue("@description", description); cmd.Parameters.AddWithValue("@autostart", autostart); cmd.Parameters.AddWithValue("@medialoop", medialoop); cmd.Parameters.AddWithValue("@dimension", dimension); cmd.Parameters.AddWithValue("@source", source); cmd.Parameters.AddWithValue("@photo", photo); cmd.Parameters.AddWithValue("@thumbnail", thumbnail); cmd.Parameters.AddWithValue("@status", status); cmd.Parameters.Add(new SqlParameter("@o_return", SqlDbType.Int) { Direction = ParameterDirection.Output }); con.Open(); int i = cmd.ExecuteNonQuery(); int retunvalue = (int)cmd.Parameters["@o_return"].Value; con.Close(); return(retunvalue); }