Ejemplo n.º 1
0
        public static bool UpdateItem(NewsInfo obj)
        {
            Dictionary <int, NewsInfo> oList = LoadList();

            if (oList != null && oList.Count > 0)
            {
                if (oList.ContainsKey(obj.Id))
                {
                    oList[obj.Id] = obj;
                    if (UpdateList(oList))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static bool InsertItem(NewsInfo obj)
        {
            Dictionary <int, NewsInfo> oList = LoadList();

            if (oList != null && oList.Count > 0)
            {
                int MaxId = 0;
                foreach (var newsInfo in oList)
                {
                    if (MaxId < newsInfo.Value.Id)
                    {
                        MaxId = newsInfo.Value.Id;
                    }
                }
                obj.Id = MaxId + 1;
                oList.Add(MaxId + 1, obj);
                if (UpdateList(oList))
                {
                    return(true);
                }
            }
            return(false);
        }