Пример #1
0
        public IssueTO Add(IssueTO Entity)
        {
            if (Entity is null)
            {
                throw new ArgumentNullException(nameof(Entity));
            }

            var issue = Entity.ToEF();

            return(issuesContext.Issues.Add(issue).Entity.ToTransfertObject());
        }
Пример #2
0
        public IssueTO Update(IssueTO Entity)
        {
            if (Entity is null)
            {
                throw new ArgumentNullException(nameof(Entity));
            }

            return(issuesContext
                   .Issues
                   .Update(Entity.ToEF())
                   .Entity
                   .ToTransfertObject());
        }
Пример #3
0
        public IssueTO Add(IssueTO Entity)
        {
            if (Entity is null)
            {
                throw new ArgumentNullException(nameof(Entity));
            }

            var issueEF = Entity.ToEF();

            issueEF.ComponentType = facilityContext.ComponentTypes.First(x => x.Id == Entity.ComponentType.Id);
            issueEF.ComponentType = issueEF.ComponentType.UpdateFromDetached(Entity.ComponentType.ToEF());

            return(facilityContext.Issues.Add(issueEF).Entity.ToTransfertObject());
        }
Пример #4
0
        public IssueTO Update(IssueTO Entity)
        {
            if (!facilityContext.Issues.Any(x => x.Id == Entity.Id && x.Archived != true))
            {
                throw new LoggedException($"IssueRepository. Update(IssueTransfertObject) no record to update.");
            }

            var attachedIssues = facilityContext.Issues
                                 .FirstOrDefault(x => x.Id == Entity.Id && x.Archived != true);

            if (attachedIssues != default)
            {
                attachedIssues.UpdateFromDetached(Entity.ToEF());
            }

            return(facilityContext.Issues.Update(attachedIssues).Entity.ToTransfertObject());
        }