public int Create(STag tag) { string sqlExpression = "sp_InsertTag"; using (SqlConnection conn = DBConnection.Instance.GetConnection()) { conn.Open(); SqlCommand command = new SqlCommand(sqlExpression, conn); command.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter urlParam = new SqlParameter { ParameterName = "@name", Value = tag.Value }; command.Parameters.Add(urlParam); var result = command.ExecuteScalar(); Console.WriteLine("Id добавленного объекта: {0}", result); string value = result.ToString(); int id = int.Parse(value); return(id); } }
private List <GroupItemModel> GetDatas(List <string> selectedList, List <GroupInfo> gInfos) { List <GroupItemModel> infos = new List <GroupItemModel>(); foreach (var item in gInfos) { infos.Add(new GroupItemModel() { IsSelected = selectedList.Contains(item.Name) ? 1 : 0, Info = item, Tags = STag.GetTags(item.MapperName) }); } return(infos); }
public void Execute([Values(false, true)] bool compile) { var model = TypeModel.Create(); model.SkipForcedLateReference = true; model.AutoCompile = compile; model.Add(typeof(SObjectSurrogate), true); model.Add(typeof(STag), true); model.Add(typeof(object), false).SetSurrogate(typeof(SObjectSurrogate)); var obj = new STag() { Type = 123, Value = new LegacyObject(1) }; var clone = model.DeepClone(obj); Assert.AreEqual(obj.Type, clone.Type); Assert.IsNotNull(obj.Value); }
public List <ArticleInfo> GetAll() { string sqlExpression = "sp_GetArticles"; CCountryGateway countryGateway = new CCountryGateway(); List <ArticleInfo> articles = new List <ArticleInfo>(); STag articleTag = new STag(); using (SqlConnection conn = DBConnection.Instance.GetConnection()) { conn.Open(); SqlCommand command = new SqlCommand(sqlExpression, conn); command.CommandType = System.Data.CommandType.StoredProcedure; using (var reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { articleTag.Value = (string)reader["Tag"]; int countryId = (int)reader["CountryID"]; ArticleInfo article = new ArticleInfo(); article.ID = (int)reader["ID"]; article.Url = (string)reader["URL"]; article.Title = (string)reader["Title"]; article.Content = (string)reader["Content"]; article.Html = (byte[])reader["HTML"]; article.Date = (DateTime)reader[6]; //todo: fix the problem with Date -> rename column? article.Country = countryGateway.Get(countryId); article.Tag = articleTag; articles.Add(article); } } } } return(articles); }
public void Update(STag tag) { throw new NotImplementedException(); }
public bool containsTag(STag tag) { return(_tags.Contains(tag)); }