public static ItemCate Insert(ItemCate param) { var dbContext = new DbContext(); var id = dbContext.ItemCateDb.InsertReturnIdentity(param); return(GetById(param.Id)); }
private static void Delete(ItemCate item) { if (mDict.Contains(item)) { mDict.Remove(item); } }
public static ItemCate Update(ItemCate param) { var dbContext = new DbContext(); dbContext.ItemCateDb.Update(param); return(GetById(param.Id)); }
public static Dictionary <string, Int32> ReadCateFile() { var path = "D:\\tb\\淘宝网 - 淘!我喜欢.html"; var text = FileHelper.ReadBinaryFile(path); var pattern = "<a.+?href=\"(.+?)\".*>(.+)</a>"; // var catStr = "cat=(\\d{1,})[&|\"]"; Dictionary <string, Int32> dict = new Dictionary <string, Int32>(100); foreach (Match match in Regex.Matches(text, pattern, RegexOptions.IgnoreCase)) { //var groups = Regex.Matches(match.Groups[1].Value, catStr, RegexOptions.IgnoreCase); //if (groups.HasValue()) //{ // var cat = groups[0].Groups[1].Value; if (dict.ContainsKey(match.Groups[2].Value) == false) { dict[match.Groups[2].Value] = 0; } //} } var temp = dict.OrderBy(d => d.Value); foreach (var item in temp) { ItemCate tempItem = new ItemCate() { CateId = item.Value, CateName = item.Key, Status = 1 }; ItemCateBLL.Insert(tempItem); Console.WriteLine(item.Key + ":" + item.Value); } Console.WriteLine("Total:" + temp.Count()); return(dict); }
public static void AddCache(ItemCate param) { if (param == null) { return; } if (GetItem(param.CateId) == null) { mDict.Add(param); } }
public async Task <bool> PutCate(string type, int id, ItemCate data) { RestClient <ItemCate> restClient = new RestClient <ItemCate>(); if (type == typeConst.Cost) { return(await restClient.PutAsync(id, data, urlConst.Cost)); } else if (type == typeConst.Income) { return(await restClient.PutAsync(id, data, urlConst.Income)); } else { return(false); } }
public async Task <bool> SaveCateAsync(string type, ItemCate data, bool isNewCate = false) { RestClient <ItemCate> restClient = new RestClient <ItemCate>(); if (type == typeConst.Cost) { return(await restClient.SaveItemAsync(data, urlConst.Cost, isNewCate)); } else if (type == typeConst.Income) { return(await restClient.SaveItemAsync(data, urlConst.Income, isNewCate)); } else { return(false); } }