Example #1
0
//This Function Post a new note in the database

        public bool postdata(mynotes obj)
        {
            if (allnote.Find(n => n.id == obj.id) == null)
            {
                allnote.Add(obj);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
//This function delete a note with a particular id in the database

        public bool deletedata(int id)
        {
            mynotes temp = allnote.Find(n => n.id == id);

            if (temp != null)
            {
                allnote.Remove(temp);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        //This function Update a particular note in the database
        public bool putdata(int id, mynotes obj)
        {
            mynotes temp = allnote.Find(n => n.id == id);

            if (temp != null)
            {
                allnote.Remove(temp);
                allnote.Add(obj);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        //This Function Post a new note in the database

        public bool postdata(mynotes obj)
        {
            using (db_obj)
            {
                if (db_obj.notes.FirstOrDefault(n => n.id == obj.id) == null)
                {
                    db_obj.Add(obj);
                    db_obj.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
//This function delete a note with a particular id in the database
        public bool deletedata(int id)
        {
            using (db_obj)
            {
                mynotes temp = db_obj.notes.FirstOrDefault(n => n.id == id);
                if (temp != null)
                {
                    db_obj.notes.Remove(temp);
                    db_obj.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }