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()); }
public IssueTO Update(IssueTO Entity) { if (Entity is null) { throw new ArgumentNullException(nameof(Entity)); } return(issuesContext .Issues .Update(Entity.ToEF()) .Entity .ToTransfertObject()); }
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()); }
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()); }