public ObservationNoteVm(ObservationNote note) { Id = note.Id; Content = note.Content; IsImportant = note.IsImportant; ObservationId = note.ObservationId; }
public static ObservationNote GetObservationNoteByID(int id) { ObservationNote observationNote = new ObservationNote(); SqlObservationNoteProvider sqlObservationNoteProvider = new SqlObservationNoteProvider(); observationNote = sqlObservationNoteProvider.GetObservationNoteByID(id); return observationNote; }
public void ObservationNoteDeleteCommandHandler_Handle() { var user = FakeObjects.TestUserWithId(); var observation = FakeObjects.TestObservationWithId(); var observationNote = FakeObjects.TestObservationNoteWithId(); ObservationNote deletedTeam = null; var command = new ObservationNoteDeleteCommand() { Id = observationNote.Id, UserId = user.Id }; using (var session = _store.OpenSession()) { session.Store(user); session.Store(observation); session.Store(observationNote); var commandHandler = new ObservationNoteDeleteCommandHandler(session); commandHandler.Handle(command); session.SaveChanges(); deletedTeam = session.Load <ObservationNote>(observationNote.Id); } Assert.IsNull(deletedTeam); }
public static ObservationNote GetObservationNoteByID(int id) { ObservationNote observationNote = new ObservationNote(); SqlObservationNoteProvider sqlObservationNoteProvider = new SqlObservationNoteProvider(); observationNote = sqlObservationNoteProvider.GetObservationNoteByID(id); return(observationNote); }
public int UpdateNote(ObservationNote note) { var newNote = _context.ObservationNotes.Find(note.Id); newNote.IsImportant = note.IsImportant; newNote.Content = note.Content; _context.Entry(newNote).State = EntityState.Modified; _context.SaveChanges(); return(newNote.Id); }
public void ObservationNote_UpdateDetails() { var testObservationNote = new ObservationNote( FakeObjects.TestUser(), FakeObjects.TestObservationWithId(), FakeValues.CommonName, FakeValues.ScientificName, FakeValues.Taxonomy, FakeValues.Tags, new Dictionary <string, string>() { { "a", "b" } }, new Dictionary <string, string>() { { "c", "d" } }, FakeValues.CreatedDateTime); var tagList = new List <string>(); tagList.AddRange(FakeValues.Tags); tagList.Add(additionalString); testObservationNote.UpdateDetails( FakeObjects.TestUser(), FakeValues.CommonName.AppendWith(additionalString), FakeValues.ScientificName.AppendWith(additionalString), FakeValues.Taxonomy.AppendWith(additionalString), tagList, new Dictionary <string, string>() { { "e", "f" } }, new Dictionary <string, string>() { { "g", "h" } } ); Assert.AreEqual(testObservationNote.CommonName, FakeValues.CommonName.AppendWith(additionalString)); Assert.AreEqual(testObservationNote.ScientificName, FakeValues.ScientificName.AppendWith(additionalString)); Assert.AreEqual(testObservationNote.Taxonomy, FakeValues.Taxonomy.AppendWith(additionalString)); Assert.AreEqual(testObservationNote.Tags, tagList); Assert.AreEqual(testObservationNote.Descriptions, new Dictionary <string, string>() { { "e", "f" } }); Assert.AreEqual(testObservationNote.References, new Dictionary <string, string>() { { "g", "h" } }); }
public void ObservationNoteCreateCommandHandler_Handle() { var user = FakeObjects.TestUserWithId(); var observation = FakeObjects.TestObservationWithId(); var createdDateTime = DateTime.UtcNow; ObservationNote newValue = null; var command = new ObservationNoteCreateCommand() { UserId = user.Id, CommonName = FakeValues.CommonName, Descriptions = new Dictionary <string, string> { { FakeValues.Description, FakeValues.Description } }, Notes = FakeValues.Notes, ObservationId = observation.Id, References = new Dictionary <string, string> { { FakeValues.Description, FakeValues.Description } }, ScientificName = FakeValues.ScientificName, NotedOn = createdDateTime, Tags = FakeValues.Tags, Taxonomy = FakeValues.Taxonomy }; using (var session = _store.OpenSession()) { session.Store(user); session.Store(observation); session.SaveChanges(); var commandHandler = new ObservationNoteCreateCommandHandler(session); commandHandler.Handle(command); session.SaveChanges(); newValue = session .Query <ObservationNote>() .SingleOrDefault(x => x.CreatedOn == createdDateTime); } Assert.IsNotNull(newValue); Assert.AreEqual(command.CommonName, newValue.CommonName); Assert.AreEqual(command.Descriptions, newValue.Descriptions); Assert.AreEqual(command.References, newValue.References); Assert.AreEqual(command.ScientificName, newValue.ScientificName); Assert.AreEqual(command.NotedOn, newValue.CreatedOn); Assert.AreEqual(command.Tags, newValue.Tags); Assert.AreEqual(command.Taxonomy, newValue.Taxonomy); //Assert.AreEqual(observation.DenormalisedObservationReference(), newValue.Observation); }
private void showObservationNoteData() { ObservationNote observationNote = new ObservationNote(); observationNote = ObservationNoteManager.GetObservationNoteByID(Int32.Parse(Request.QueryString["observationNoteID"])); txtNote.Text = observationNote.Note; ddlResident.SelectedValue = observationNote.ResidentID.ToString(); txtAddeBy.Text = observationNote.AddeBy.ToString(); txtExtraField1.Text = observationNote.ExtraField1; txtExtraField2.Text = observationNote.ExtraField2; txtExtraField3.Text = observationNote.ExtraField3; txtExtraField4.Text = observationNote.ExtraField4; txtExtraField5.Text = observationNote.ExtraField5; }
protected void btnAdd_Click(object sender, EventArgs e) { ObservationNote observationNote = new ObservationNote(); observationNote.Note = txtNote.Text; observationNote.ResidentID = Int32.Parse(ddlResident.SelectedValue); observationNote.AddeBy = Int32.Parse(txtAddeBy.Text); observationNote.AddedDate = DateTime.Now; observationNote.ExtraField1 = txtExtraField1.Text; observationNote.ExtraField2 = txtExtraField2.Text; observationNote.ExtraField3 = txtExtraField3.Text; observationNote.ExtraField4 = txtExtraField4.Text; observationNote.ExtraField5 = txtExtraField5.Text; int resutl = ObservationNoteManager.InsertObservationNote(observationNote); Response.Redirect("AdminObservationNoteDisplay.aspx"); }
protected void btnAdd_Click(object sender, EventArgs e) { ObservationNote observationNote = new ObservationNote(); observationNote.Note = txtObservationOrComment.Text; observationNote.ResidentID = Int32.Parse(Request.QueryString["ResidentID"]); observationNote.AddeBy = getLogin().LoginID; observationNote.AddedDate = DateTime.Parse(DateTime.Parse(txtDate.Text).ToString("yyyy-MM-dd") + " " + txtTakingTime.Text); observationNote.ExtraField1 = txtMadeBy.Text; observationNote.ExtraField2 = ddlObservationType.SelectedValue; observationNote.ExtraField3 = ""; observationNote.ExtraField4 = ""; observationNote.ExtraField5 = ""; int resutl = ObservationNoteManager.InsertObservationNote(observationNote); loadGrid(); }
public Observation UpdateObservationDbFromObservationVm(Observation observation, ObservationVm observationVm) { observation.CycleId = _observationRepository.UpdateCycleId(observationVm.ParentChartId, observationVm.NumberOfParentCycleInChart); observation.NumberInCycle = observationVm.NumberInCycle; observation.Marker = _observationRepository.GetMarkerByValue(observationVm.Marker).FirstOrDefault(); observation.PeakDayNumber = observationVm.PeakDayNumber; observation.Date = observationVm.Date; observation.Letter = _observationRepository.GetLetterByValue(observationVm.Letter).FirstOrDefault(); observation.IsB = observationVm.IsB; observation.NumTimes = _observationRepository.GetNumTimesByValue(observationVm.NumTimes).FirstOrDefault(); observation.Cipher = _observationRepository.GetCipherByValue(observationVm.Cipher).FirstOrDefault(); observation.CipherCd = _observationRepository.GetCipherCdByValue(observationVm.CipherCd).FirstOrDefault(); //comments. notes, pictures //public int? CommentId { get; set; } //public virtual IList<Comment> Comments { get; set; } foreach (var item in observationVm.Notes) { ObservationNote note = new ObservationNote() { Id = item.Id, IsImportant = item.IsImportant, Content = item.Content, ObservationId = item.ObservationId }; if (item.Content != "") { if (item.Id != 0) { _observationRepository.UpdateNote(note); } else { _observationRepository.AddNote(note); } } else if (item.Id != 0) { _observationRepository.DeleteNote(note); } } return(observation); }
protected void btnUpdate_Click(object sender, EventArgs e) { ObservationNote observationNote = new ObservationNote(); observationNote = ObservationNoteManager.GetObservationNoteByID(Int32.Parse(Request.QueryString["observationNoteID"])); ObservationNote tempObservationNote = new ObservationNote(); tempObservationNote.ObservationNoteID = observationNote.ObservationNoteID; tempObservationNote.Note = txtNote.Text; tempObservationNote.ResidentID = Int32.Parse(ddlResident.SelectedValue); tempObservationNote.AddeBy = Int32.Parse(txtAddeBy.Text); tempObservationNote.AddedDate = DateTime.Now; tempObservationNote.ExtraField1 = txtExtraField1.Text; tempObservationNote.ExtraField2 = txtExtraField2.Text; tempObservationNote.ExtraField3 = txtExtraField3.Text; tempObservationNote.ExtraField4 = txtExtraField4.Text; tempObservationNote.ExtraField5 = txtExtraField5.Text; bool result = ObservationNoteManager.UpdateObservationNote(tempObservationNote); Response.Redirect("AdminObservationNoteDisplay.aspx"); }
public bool UpdateObservationNote(ObservationNote observationNote) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("AL_UpdateObservationNote", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ObservationNoteID", SqlDbType.Int).Value = observationNote.ObservationNoteID; cmd.Parameters.Add("@Note", SqlDbType.NText).Value = observationNote.Note; cmd.Parameters.Add("@ResidentID", SqlDbType.Int).Value = observationNote.ResidentID; cmd.Parameters.Add("@AddeBy", SqlDbType.Int).Value = observationNote.AddeBy; cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = observationNote.AddedDate; cmd.Parameters.Add("@ExtraField1", SqlDbType.NVarChar).Value = observationNote.ExtraField1; cmd.Parameters.Add("@ExtraField2", SqlDbType.NVarChar).Value = observationNote.ExtraField2; cmd.Parameters.Add("@ExtraField3", SqlDbType.NVarChar).Value = observationNote.ExtraField3; cmd.Parameters.Add("@ExtraField4", SqlDbType.NVarChar).Value = observationNote.ExtraField4; cmd.Parameters.Add("@ExtraField5", SqlDbType.NVarChar).Value = observationNote.ExtraField5; connection.Open(); int result = cmd.ExecuteNonQuery(); return(result == 1); } }
public ObservationNote GetObservationNoteFromReader(IDataReader reader) { try { ObservationNote observationNote = new ObservationNote ( (int)reader["ObservationNoteID"], reader["Note"].ToString(), (int)reader["ResidentID"], (int)reader["AddeBy"], (DateTime)reader["AddedDate"], reader["ExtraField1"].ToString(), reader["ExtraField2"].ToString(), reader["ExtraField3"].ToString(), reader["ExtraField4"].ToString(), reader["ExtraField5"].ToString() ); return(observationNote); } catch (Exception ex) { return(null); } }
public void ObservationNote_Constructor() { var testObservation = new ObservationNote( FakeObjects.TestUserWithId(), FakeObjects.TestObservationWithId(), FakeValues.CommonName, FakeValues.ScientificName, FakeValues.Taxonomy, FakeValues.Tags, new Dictionary <string, string>() { { "a", "b" } }, new Dictionary <string, string>() { { "c", "d" } }, FakeValues.CreatedDateTime); Assert.AreEqual(testObservation.CommonName, FakeValues.CommonName); Assert.AreEqual(testObservation.ScientificName, FakeValues.ScientificName); Assert.AreEqual(testObservation.Taxonomy, FakeValues.Taxonomy); Assert.AreEqual(testObservation.Tags, FakeValues.Tags); Assert.AreEqual(testObservation.Observation.Id, FakeObjects.TestObservationWithId().Id); Assert.AreEqual(testObservation.User.FirstName, FakeObjects.TestUserWithId().FirstName); Assert.AreEqual(testObservation.User.LastName, FakeObjects.TestUserWithId().LastName); Assert.AreEqual(testObservation.User.Id, FakeObjects.TestUserWithId().Id); Assert.AreEqual(testObservation.Descriptions, new Dictionary <string, string>() { { "a", "b" } }); Assert.AreEqual(testObservation.References, new Dictionary <string, string>() { { "c", "d" } }); }
public static bool UpdateObservationNote(ObservationNote observationNote) { SqlObservationNoteProvider sqlObservationNoteProvider = new SqlObservationNoteProvider(); return sqlObservationNoteProvider.UpdateObservationNote(observationNote); }
public static int InsertObservationNote(ObservationNote observationNote) { SqlObservationNoteProvider sqlObservationNoteProvider = new SqlObservationNoteProvider(); return sqlObservationNoteProvider.InsertObservationNote(observationNote); }
public int AddNote(ObservationNote note) { _context.ObservationNotes.Add(note); _context.SaveChanges(); return(note.Id); }
public bool UpdateObservationNote(ObservationNote observationNote) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("AL_UpdateObservationNote", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ObservationNoteID", SqlDbType.Int).Value = observationNote.ObservationNoteID; cmd.Parameters.Add("@Note", SqlDbType.NText).Value = observationNote.Note; cmd.Parameters.Add("@ResidentID", SqlDbType.Int).Value = observationNote.ResidentID; cmd.Parameters.Add("@AddeBy", SqlDbType.Int).Value = observationNote.AddeBy; cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = observationNote.AddedDate; cmd.Parameters.Add("@ExtraField1", SqlDbType.NVarChar).Value = observationNote.ExtraField1; cmd.Parameters.Add("@ExtraField2", SqlDbType.NVarChar).Value = observationNote.ExtraField2; cmd.Parameters.Add("@ExtraField3", SqlDbType.NVarChar).Value = observationNote.ExtraField3; cmd.Parameters.Add("@ExtraField4", SqlDbType.NVarChar).Value = observationNote.ExtraField4; cmd.Parameters.Add("@ExtraField5", SqlDbType.NVarChar).Value = observationNote.ExtraField5; connection.Open(); int result = cmd.ExecuteNonQuery(); return result == 1; } }
public ObservationNote GetObservationNoteFromReader(IDataReader reader) { try { ObservationNote observationNote = new ObservationNote ( (int)reader["ObservationNoteID"], reader["Note"].ToString(), (int)reader["ResidentID"], (int)reader["AddeBy"], (DateTime)reader["AddedDate"], reader["ExtraField1"].ToString(), reader["ExtraField2"].ToString(), reader["ExtraField3"].ToString(), reader["ExtraField4"].ToString(), reader["ExtraField5"].ToString() ); return observationNote; } catch(Exception ex) { return null; } }
public static bool UpdateObservationNote(ObservationNote observationNote) { SqlObservationNoteProvider sqlObservationNoteProvider = new SqlObservationNoteProvider(); return(sqlObservationNoteProvider.UpdateObservationNote(observationNote)); }
public static int InsertObservationNote(ObservationNote observationNote) { SqlObservationNoteProvider sqlObservationNoteProvider = new SqlObservationNoteProvider(); return(sqlObservationNoteProvider.InsertObservationNote(observationNote)); }
public bool DeleteNote(ObservationNote note) { _context.ObservationNotes.Remove(note); _context.SaveChanges(); return(true); }