Пример #1
0
        public void AddNote_Success()
        {
            //Act
            Mock_Note();
            var addNote = new NoteModel
            {
                NoteID           = 2,
                ContactID        = 1,
                NoteTypeID       = 1,
                Notes            = "",
                TakenBy          = 1,
                TakenTime        = DateTime.Now,
                NoteStatusID     = 1,
                DocumentStatusID = 1,
                EncounterID      = null,
                ForceRollback    = true
            };

            var addNoteResult = noteController.AddNote(addNote);
            var response      = addNoteResult as HttpResult <Response <NoteModel> >;

            //Assert
            Assert.IsNotNull(response, "Response can't be null");
            Assert.IsNotNull(response.Value, "Response value can't be null");
            Assert.IsNotNull(response.Value.DataItems, "Response value can't be null");
            Assert.IsTrue(response.Value.DataItems.Count == 2, "Note could not be created.");
        }
Пример #2
0
        public async Task TestAddNote_Success()
        {
            _fixture.CareAgentUserName = "******";
            var response = await _controller.AddNote(new AddNoteRequest { Note = "test", UserFullName = "GordenJames", AccountIdentifier = "1A552781-373A-4F2C-87D8-EDFCB40767F9" });

            Assert.NotNull(response);
            return;
        }
Пример #3
0
        private void btnRestoreTrash_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < flpTrash.Controls.Count; i++)
            {
                if (flpTrash.Controls[i].BackColor == Color.LightGray)
                {
                    TrashController.RefreshTrash();
                    Trash trash = TrashController.GetTrash(i);
                    Note  note  = new Note();

                    note.ID          = NoteController.GetListNote().Count;
                    note.description = trash.description;
                    note.dateCreated = trash.dateCreated;
                    note.tags        = trash.tags;
                    note.isPinned    = trash.isPinned;

                    TrashController.DeleteForever(trash);
                    TrashController.RefreshTrash();
                    NoteController.AddNote(note);


                    flpTrash.Controls.Remove(flpTrash.Controls[i]);
                    this.richTextBoxTrashDescription.Text = "";
                }
            }
        }
Пример #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Note note = new Note();

            note.FileName = this.Text.ToString();
            note.note     = rtbNote.Text.ToString();

            NoteController.AddNote(note);
        }
Пример #5
0
        public void AddNote_Success()
        {
            // Arrange
            //PrepareResponse(noteDataForSuccess);
            notes        = new List <NoteModel>();
            noteResponse = new Response <NoteModel>()
            {
                DataItems = notes
            };

            mock.Setup(r => r.AddNote(It.IsAny <NoteModel>()))
            .Callback((NoteModel noteModel) => { if (noteModel.NoteID > 0)
                                                 {
                                                     notes.Add(noteModel);
                                                 }
                      })
            .Returns(noteResponse);

            //Act
            var addNote = new NoteModel()
            {
                NoteID           = 2,
                ContactID        = 1,
                NoteTypeID       = 1,
                Notes            = "",
                TakenBy          = 1,
                TakenTime        = DateTime.Now,
                NoteStatusID     = 1,
                DocumentStatusID = 1,
                EncounterID      = null,
                ForceRollback    = true
            };

            var addNoteResult = noteController.AddNote(addNote);
            var response      = addNoteResult as HttpResult <Response <NoteModel> >;

            //Assert
            Assert.IsNotNull(response, "Response can't be null");
            Assert.IsNotNull(response.Value, "Response value can't be null");
            Assert.IsNotNull(response.Value.DataItems, "Response value can't be null");
            Assert.IsTrue(response.Value.DataItems.Count == 1, "Note could not be created.");
        }
Пример #6
0
        public void AddNote_Success()
        {
            // Act
            var noteModel = new NoteViewModel
            {
                NoteID           = 0,
                ContactID        = 1,
                NoteTypeID       = 1,
                Notes            = "",
                TakenBy          = 1,
                TakenTime        = DateTime.Now,
                NoteStatusID     = 1,
                DocumentStatusID = 1,
                EncounterID      = null,
                ForceRollback    = true
            };

            var response = controller.AddNote(noteModel);

            // Assert
            Assert.IsNotNull(response, "Response can not be null");
            Assert.IsTrue(response.RowAffected > 0, "Note could not be created.");
        }
        private async void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (!Valid())
            {
                MessageBox.Show("请检查你的输入");
            }
            else
            {
                ShowLoadingAnimation();

                Note note = new Note()
                {
                    NoteType = cmbType.Text, NoteTitle = txtTitle.Text, NoteContent = txtContent.Text, UserName = _currentUser.UserName
                };
                if (_isEdit)
                {
                    var result = await Task.Run(() => _lcController.UpdateNote(note, _oldNote, _currentUser));

                    ShowLoadingAnimation(false);
                    if (result == true)
                    {
                        MessageBox.Show("更新日报成功!");
                        DialogResult = true;
                    }
                    else
                    {
                        MessageBox.Show("更新日报失败!");
                    }
                }
                else
                {
                    var result = await Task.Run(() => _lcController.AddNote(note, _currentUser));

                    ShowLoadingAnimation(false);
                    if (result)
                    {
                        MessageBox.Show("新增日报成功!");
                        DialogResult = true;
                    }
                    else
                    {
                        MessageBox.Show("新增日报失败!");
                    }
                }
            }
        }
Пример #8
0
        private void button_Add_Click(object sender, EventArgs e)
        {
            toolStripButton_loading.Visible = true;
            Note _note = new Note();
            var  id    = NoteController.getIDfromDB(this.currentUser.UserName);

            _note.ID           = id;
            _note.Title_Note   = this.textBox_TitleNote.Text;
            _note.RichTextNote = this.richText_Note.Text;
            _note.User_k       = this.currentUser.UserName;
            _note.Size         = int.Parse(this.richText_Note.Font.Size.ToString());
            _note.ColorText    = this.richText_Note.ForeColor.ToString();
            _note.ColorBg      = this.richText_Note.BackColor.ToString();
            _note.Font         = this.richText_Note.Font.Name;

            if (_note.Title_Note == "")
            {
                _note.Title_Note = "Note " + id.ToString();
            }
            if (this._listImage.Count() > 0)
            {
                try
                {
                    for (int i = 0; i < this._listImage.Count(); i++)
                    {
                        this._listImage[i].Save(string.Format("{0}.jpg", id + _note.User_k + i));
                    }
                    this._listImage.Clear();
                }
                catch { }
            }
            // add bằng DB
            if (NoteController.AddNote(_note))
            {
                MessageBox.Show("Add note secessfull ");
            }

            this.textBox_TitleNote.ResetText();
            this.richText_Note.ResetText();
            DisplayNote();
            toolStripButton_loading.Visible = false;
            resetRichText();
        }
Пример #9
0
        private void richTextBoxDescription_TextChanged(object sender, EventArgs e)
        {
            if (flpNote.Controls.Count <= 0)
            {
                return;
            }

            for (int i = 0; i < flpNote.Controls.Count; i++)
            {
                if (flpNote.Controls[i].BackColor == Color.LightGray)
                {
                    if (i >= NoteController.GetListNote().Count)
                    {
                        break;
                    }

                    Note note = NoteController.GetNote(i);
                    if (string.IsNullOrEmpty(note.tags))
                    {
                        note.tags = "";
                        for (int j = this.flpTags.Controls.Count - 1; j >= 0; j--)
                        {
                            Control c = this.flpTags.Controls[j];
                            if (c.GetType() != typeof(TextBox))
                            {
                                this.flpTags.Controls.RemoveAt(j);
                            }
                        }

                        break;
                    }
                }
            }

            // add note & save note by changing text (?)
            if (richTextBoxDescription.Text.Length > 0)
            {
                Note note = new Note();

                note.description = this.richTextBoxDescription.Text.Trim();


                for (int i = 0; i < flpNote.Controls.Count; i++)
                {
                    if (flpNote.Controls[i].BackColor == Color.LightGray)
                    {
                        if (NoteController.GetNote(i) is null)
                        {
                            note.tags        = "";
                            note.dateCreated = DateTime.Now;
                            break;
                        }
                        Note n = NoteController.GetNote(i);
                        note.dateCreated = n.dateCreated;
                        note.isPinned    = n.isPinned;
                        if (string.IsNullOrEmpty(n.tags))
                        {
                            note.tags = "";
                        }
                        else
                        {
                            note.tags = n.tags;
                        }
                        break;
                    }
                }

                int index = 0;

                for (int i = 0; i < flpNote.Controls.Count; i++)
                {
                    if (flpNote.Controls[i].BackColor == Color.LightGray)
                    {
                        index = i;
                        break;
                    }
                }

                if (NoteController.GetNote(index) != null)
                {
                    note.ID = index;
                    NoteController.UpdateNote(note);
                }
                else
                {
                    note.ID = this.ID;
                    NoteController.AddNote(note);
                }

                flpNote.Controls[index].Text = note.description;
            }
        }