public ICollection <AnnotationsDTO> GetAnnotationsByMarkingId(int id) { using (var db = new SovaContext()) { var annotation = db.Annotations.Where(i => i.MarkedPostId == id).ToList(); List <AnnotationsDTO> annotationsDTO = new List <AnnotationsDTO>(); foreach (var item in annotation) { var newAnntoation = new AnnotationsDTO(item.AnnotationId, item.MarkedPostId, item.Annotation, item.Marking, item.From, item.To); annotationsDTO.Add(newAnntoation); } return(annotationsDTO); } }
public ICollection <AnnotationsDTO> GetAnnotations() { using (var db = new SovaContext()) { var annotations = db.Annotations.ToList(); if (annotations != null) { List <AnnotationsDTO> AnnotationsDTO = new List <AnnotationsDTO>(); foreach (var annotation in annotations) { var newAnn = new AnnotationsDTO(annotation.AnnotationId, annotation.MarkedPostId, annotation.Annotation, annotation.Marking, annotation.From, annotation.To); AnnotationsDTO.Add(newAnn); } return(AnnotationsDTO); } return(null); } }