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); }