Exemplo n.º 1
0
        public bool Update(DemoModel newObj)
        {
            bool isUpdated = false;

            varifyObj(newObj);

            for (int index = 0; index < ObjList.Count; index++)
            {
                if (ObjList[index].Id == newObj.Id)
                {
                    ObjList[index].Name = newObj.Name;
                    ObjList[index].Age  = newObj.Age;
                    isUpdated           = true;
                    break;
                }
            }

            return(isUpdated);
        }
Exemplo n.º 2
0
        public bool AddObj(DemoModel newObj)
        {
            if (newObj == null)
            {
                throw new Exception("Please enter the correct value");
            }

            varifyObj(newObj);

            int objIndex = getObjIndex(newObj.Id);

            if (objIndex == -1)
            {
                ObjList.Add(new DemoModel {
                    Age = newObj.Age, Id = newObj.Id, Name = newObj.Name
                });
            }
            else
            {
                Update(newObj);
            }
            return(true);
        }
Exemplo n.º 3
0
 void varifyObj(DemoModel newObj)
 {
     varifyObjAge(newObj.Age);
 }