Example #1
0
        public static CommentEF UpdateFromDetached(this CommentEF attachedEF, CommentEF detachedEF)
        {
            if (attachedEF is null)
            {
                throw new ArgumentNullException(nameof(attachedEF));
            }

            if (detachedEF is null)
            {
                throw new ArgumentNullException(nameof(detachedEF));
            }

            if (attachedEF.Id != detachedEF.Id)
            {
                throw new Exception("Cannot update CommentEF entity as it is not the same.");
            }

            if ((attachedEF != default) && (detachedEF != default))
            {
                attachedEF.Incident   = detachedEF.Incident;
                attachedEF.Message    = detachedEF.Message;
                attachedEF.SubmitDate = detachedEF.SubmitDate;
                attachedEF.UserId     = detachedEF.UserId;
            }

            return(attachedEF);
        }
Example #2
0
        public static CommentTO ToTransfertObject(this CommentEF comment)
        {
            if (comment is null)
            {
                throw new ArgumentNullException(nameof(comment));
            }

            return(new CommentTO
            {
                Id = comment.Id,
                Content = comment.Content,
            });
        }
Example #3
0
        public static CommentTO ToTransfertObject(this CommentEF comment)
        {
            if (comment is null)
            {
                throw new ArgumentNullException(nameof(comment));
            }

            return(new CommentTO
            {
                Id = comment.Id,
                Incident = comment.Incident.ToTransfertObject(),
                Message = comment.Message,
                SubmitDate = comment.SubmitDate,
                UserId = comment.UserId,
            });
        }