/// <summary> /// SOMETHING. /// </summary> /// <param name="meetingId">Meeting Id.</param> /// <returns>Action Result.</returns> public async Task <IActionResult> Index(Guid meetingId) { IWho who = this.Who(); this.logger.ReportEntry( who, new { MeetingId = meetingId }); IMeeting meeting = await this.service.GetMeetingByIdAsync( who, meetingId).ConfigureAwait(false); IAgendaItem agendaItem = await this.service.GetAgendaItemsByMeetingIdAsTreeAsync( who, meetingId).ConfigureAwait(false); if (agendaItem == null) { agendaItem = await this.service.CreateSkeletonAgendaAsync( who, AuditEvent.ViewAgenda, meetingId, SkeletonAgendaType.BasicContinuation).ConfigureAwait(false); } _ = meeting; _ = agendaItem; throw new NotImplementedException(); ////return this.View(); }
/// <inheritdoc/> public async Task CreateAgendaItemRecursivelyAsync( IWho who, IAuditHeaderWithAuditDetails auditHeader, IAgendaItem agendaItem) { AgendaItemDto dto = AgendaItemDto.ToDto(agendaItem); this.context.AgendaItems.Add(dto); Audit.AuditCreate(auditHeader, dto, dto.Id); foreach (IAgendaItem child in agendaItem.ChildAgendaItems) { await this.CreateAgendaItemRecursivelyAsync( who, auditHeader, child); } if (agendaItem.ParentId == null) { this.logger.Debug( who, "Saving changes", new { AgendaItemId = agendaItem }); await this.context.SaveChangesAsync(); } this.logger.ReportExit(who); }
/// <summary> /// Converts domain object to DTO. /// </summary> /// <param name="agendaItem">Agenda Item.</param> /// <returns>Agenda Item DTO.</returns> public static AgendaItemDto ToDto(IAgendaItem agendaItem) { if (agendaItem == null) { throw new ArgumentNullException(nameof(agendaItem)); } return(new AgendaItemDto( id: agendaItem.Id, meetingId: agendaItem.MeetingId, parentId: agendaItem.ParentId, elderSiblingId: agendaItem.ElderSiblingId, text: agendaItem.Text, agendaItemType: agendaItem.AgendaItemType, childNumberingType: agendaItem.ChildNumberingType)); }
/// <inheritdoc/> public async Task UpdateAgendaItemAsync( IWho who, IAuditHeaderWithAuditDetails auditHeader, IAgendaItem agendaItem) { this.logger.ReportEntry( who, new { AgendaItem = agendaItem }); AgendaItemDto dto = AgendaItemDto.ToDto(agendaItem); AgendaItemDto original = await this.context.FindAsync <AgendaItemDto>(agendaItem.Id); Audit.AuditUpdate(auditHeader, dto.Id, original, dto); this.context.Entry(original).CurrentValues.SetValues(dto); await this.context.SaveChangesAsync().ConfigureAwait(false); this.logger.ReportExit(who); }
/// <summary> /// Create an agenda item tree structure from a list of agenda items. /// </summary> /// <param name="agendaItems">List of agenda items.</param> /// <returns>Agenda Item tree structure.</returns> public static IAgendaItem CreateTreeStructure(IList <IAgendaItem> agendaItems) { IAgendaItem root = agendaItems.Single(ai => ai.ParentId == null); foreach (IAgendaItem agendaItem in agendaItems.Where(ai => ai.Id != root.Id)) { IAgendaItem parent = agendaItems .Single(ai => ai.Id == agendaItem.ParentId); parent.AddChild(agendaItem); } foreach (IAgendaItem agendaItem in agendaItems) { agendaItem.SortChildAgendaItems(); } return(root); }
/// <inheritdoc/> public async Task <IAgendaItem> CreateSkeletonAgendaAsync( IWho who, AuditEvent auditEvent, Guid meetingId, SkeletonAgendaType skeletonAgendaType) { this.logger.ReportEntry( who, new { AuditEvent = auditEvent, MeetingId = meetingId, SkeletonAgendaType = skeletonAgendaType }); SkeletonAgendaFactory factory = new SkeletonAgendaFactory(); IAgendaItem agendaItem = factory.Create(meetingId, skeletonAgendaType); try { IAuditHeaderWithAuditDetails auditHeader = this.data.BeginTransaction(auditEvent, who); await this.data.CreateAgendaItemRecursivelyAsync( who, auditHeader, agendaItem).ConfigureAwait(false); await this.data.CommitTransactionAsync(auditHeader) .ConfigureAwait(false); } catch (Exception) { this.data.RollbackTransaction(); throw; } this.logger.ReportExit( who, new { AgendaItem = agendaItem }); return(agendaItem); }
/// <inheritdoc/> public async Task <IAgendaItem> GetAgendaItemByIdAsync( IWho who, Guid agendaItemId) { this.logger.ReportEntry( who, new { AgendaItemId = agendaItemId }); IAgendaItem agendaItem = (await this.context.AgendaItems .AsNoTracking() .TagWith(this.Tag(who)) .FirstOrDefaultAsync(ai => ai.Id == agendaItemId) .ConfigureAwait(false)) .ToDomain(); this.logger.ReportExit( who, new { AgendaItem = agendaItem }); return(agendaItem); }
/// <inheritdoc/> public void AddChild(IAgendaItem child) { this.childAgendaItems.Add(child); }