コード例 #1
0
        public bool CreateNote(string login, string password, string title)
        {
            using (NotesAppEntities context = new NotesAppEntities())
            {
                try
                {
                    var entity = context.Member.FirstOrDefault(x => x.Email == login && x.Password == password);

                    if (entity != null)
                    {
                        entity.Note.Add(new Note()
                        {
                            Title = title
                        });

                        context.SaveChanges();
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
            return(false);
        }
コード例 #2
0
        public bool UpdateNote(string login, string password, string title, string content)
        {
            using (NotesAppEntities context = new NotesAppEntities())
            {
                try
                {
                    var entity = context.Member.FirstOrDefault(x => x.Email == login && x.Password == password);

                    if (entity != null)
                    {
                        var noteEntity = entity.Note.FirstOrDefault(x => x.Title == title);

                        noteEntity.Text = content;

                        context.SaveChanges();
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
            return(false);
        }