Exemple #1
0
        public CommentTO Update(CommentTO Entity)
        {
            if (Entity is null)
            {
                throw new ArgumentNullException(nameof(Entity));
            }

            var comment = facilityContext.Comments
                          .Include(c => c.Incident)
                          .ThenInclude(i => i.Issue)
                          .ThenInclude(i => i.ComponentType)
                          .Include(x => x.Incident)
                          .ThenInclude(i => i.Room)
                          .ThenInclude(r => r.Floor)
                          .FirstOrDefault(c => c.Id == Entity.Id);

            if (comment == null)
            {
                throw new KeyNotFoundException($"CommentRepository. Update(commentTO) wrong ID (ID <= 0).");
            }

            comment.UpdateFromDetached(Entity.ToEF());

            var updatedComment = facilityContext.Comments.Update(comment);

            updatedComment.State = EntityState.Detached;
            return(updatedComment.Entity.ToTransfertObject());
        }
Exemple #2
0
        public CommentTO Add(CommentTO Entity)
        {
            var comment = Entity.ToEF();

            comment.Response = evaluationContext.Responses.First(r => r.Id == Entity.Response.Id);

            return(evaluationContext.Comments.Add(comment).Entity.ToTransfertObject());
        }
Exemple #3
0
        public CommentTO Add(CommentTO Entity)
        {
            if (Entity is null)
            {
                throw new ArgumentNullException(nameof(Entity));
            }

            var comment = Entity.ToEF();

            comment.Incident = facilityContext.Incidents.First(c => c.Id == Entity.Incident.Id);

            return(facilityContext.Comments.Add(comment).Entity.ToTransfertObject());
        }