public string Edit(FormDataCollection form) { var retVal = string.Empty; var operation = form.Get("oper"); var id = form.Get("Id").Split(',')[0].ToInt32(); if (string.IsNullOrEmpty(operation)) return retVal; SearchKeywordInfo info; switch (operation) { case "edit": info = CatalogRepository.GetInfo<SearchKeywordInfo>(id); if (info != null) { info.Name = form.Get("Name"); CatalogRepository.Update(info); } break; case "add": info = new SearchKeywordInfo { Name = form.Get("Name") }; CatalogRepository.Create(info); break; case "del": CatalogRepository.Delete<SearchKeywordInfo>(id); break; } StoreData.ReloadData<SearchKeywordInfo>(); return retVal; }
public static int GetSearchKeywordId(string value) { if (_SearchKeywords.IsNullOrEmpty()) _SearchKeywords = CatalogRepository.GetAll<SearchKeywordInfo>(); var entity = _SearchKeywords.FirstOrDefault(c => c.Name.Equals(value, StringComparison.CurrentCultureIgnoreCase)); if (entity == null) { entity = new SearchKeywordInfo { Name = value }; entity.Id = CatalogRepository.Create(entity); _SearchKeywords.Add(entity); } return entity.Id; }