public async Task <Guid> HandleAsync(SetTechnologyEmployed command) { var technologyEmployed = await technologyEmployedRepository.GetByNotificaitonId(command.NotificationId); if (technologyEmployed == null) { technologyEmployed = command.AnnexProvided ? TechnologyEmployed.CreateTechnologyEmployedWithAnnex(command.NotificationId, command.Details) : TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(command.NotificationId, command.Details, command.FurtherDetails); context.TechnologiesEmployed.Add(technologyEmployed); } else { if (command.AnnexProvided) { technologyEmployed.SetWithAnnex(command.Details); } else { technologyEmployed.SetWithFurtherDetails(command.Details, command.FurtherDetails); } } await context.SaveChangesAsync(); return(technologyEmployed.Id); }
private async Task CloneTechnologyEmployed(Guid sourceNotificationId, Guid destinationNotificationId) { var technologyEmployed = await context.TechnologiesEmployed.SingleOrDefaultAsync(p => p.NotificationId == sourceNotificationId); if (technologyEmployed != null) { TechnologyEmployed destinationTechnologyEmployed; if (technologyEmployed.AnnexProvided) { destinationTechnologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithAnnex(destinationNotificationId, technologyEmployed.Details); } else { destinationTechnologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails( destinationNotificationId, technologyEmployed.Details, technologyEmployed.FurtherDetails); } context.TechnologiesEmployed.Add(destinationTechnologyEmployed); await context.SaveChangesAsync(); } }
public void CanAddTechnologyDetailsInAnnex() { var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithAnnex(notificationId, "details"); Assert.True(technologyEmployed.AnnexProvided); }
private void AddTechnologyEmployed(Guid id) { var technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithAnnex(id, "test"); context.TechnologiesEmployed.Add(technologyEmployed); }