internal void DeleteNote(IncomingNoteRequest note)
        {
            var currentNote = Context.UserNotes.FirstOrDefault(x => x.Id == note.NoteId);

            Context.UserNotes.Remove(currentNote);
            var associatedNotes = Context.AssociatedAccountNotes.Where(x => x.NoteId == note.NoteId).ToList();

            Context.AssociatedAccountNotes.RemoveRange(associatedNotes);
            Context.SaveChanges();
        }
        internal void ChangeNotePosition(IncomingNoteRequest note)
        {
            var currentNote = Context.UserNotes.FirstOrDefault(x => x.Id == note.NoteId);

            currentNote.TopPos  = note.Top;
            currentNote.LeftPos = note.Left;
            Context.Attach(currentNote);
            Context.Update(currentNote);
            Context.SaveChanges();
        }
        internal void EditNote(IncomingNoteRequest note)
        {
            var currentNote = Context.UserNotes.FirstOrDefault(x => x.Id == note.NoteId);

            currentNote.NoteBackground = note.Background;
            currentNote.NoteForeground = note.FontColor;
            currentNote.Content        = note.Content;
            Context.Attach(currentNote);
            Context.Update(currentNote);
            Context.SaveChanges();
        }
        public OutgoingJsonData EditNote([FromBody] IncomingNoteRequest note)
        {
            using (var context = new NotesContext(Context, Configuration))
            {
                context.EditNote(note);
            }

            return(new OutgoingJsonData {
                Data = ""
            });
        }
        public List <Notifications> GetUserNotifications([FromBody] IncomingNoteRequest note)
        {
            var result = new List <Notifications>();

            using (var context = new NotificationContext(Context, Configuration))
            {
                result = context.GetAllUserNotifications(UserId, note.ProjectId);
            }

            return(result);
        }
        public List <Notifications> GetUserNotifications([FromBody] IncomingNoteRequest note)
        {
            var result      = new List <Notifications>();
            var currentUser = this.User;
            var id          = int.Parse(currentUser.Claims.ElementAt(1).Value);

            using (var context = new DatabaseController(Context, Configuration))
            {
                result = context.GetAllUserNotifications(id, note.ProjectId);
            }

            return(result);
        }
        public OutgoingJsonData EditNote([FromBody] IncomingNoteRequest note)
        {
            var currentUser = this.User;
            var id          = int.Parse(currentUser.Claims.ElementAt(1).Value);

            using (var context = new DatabaseController(Context, Configuration))
            {
                context.EditNote(note);
            }

            return(new OutgoingJsonData {
                Data = ""
            });
        }
        internal void AddNewUserNote(IncomingNoteRequest note, int id)
        {
            var currentNote = Context.UserNotes.Add(new UserNotes {
                Content        = note.Content,
                DateOfMessage  = DateTime.Now,
                NoteBackground = note.Background,
                NoteForeground = note.FontColor
            });

            Context.SaveChanges();
            Context.AssociatedAccountNotes.Add(new AssociatedAccountNotes {
                NoteId        = currentNote.Entity.Id,
                ProjectId     = note.ProjectId,
                UserAccountId = id
            });
            Context.SaveChanges();
        }