Beispiel #1
0
        private async Task UpdateBulletin(ProtectionDoc protectionDoc, ProtectionDocDetailsDto details)
        {
            var relation = protectionDoc.Bulletins.FirstOrDefault(b => b.IsPublish);

            if (relation != null)
            {
                relation.BulletinId = details.BulletinId ?? 0;
                await Executor.GetCommand <UpdateProtectionDocBulletinRelationCommand>()
                .Process(c => c.ExecuteAsync(relation));
            }
        }
Beispiel #2
0
 public async Task Handle(ProtectionDoc protectionDoc, ProtectionDocDetailsDto protectionDocDetailsDto)
 {
     await ApplyIcgsProtectionDoc(protectionDoc, protectionDocDetailsDto.IcgsRequestDtos);
     await ApplyIcisIds(protectionDoc, protectionDocDetailsDto.IcisRequestIds.ToList());
     await ApplyColorIds(protectionDoc, protectionDocDetailsDto.ColorTzIds.ToList());
     await ApplyProtectionDocInfo(protectionDocDetailsDto, protectionDoc);
     await ApplyProtectionDocEarlyRegDtos(protectionDoc, protectionDocDetailsDto.RequestEarlyRegDtos);
     await ApplyIcfemIds(protectionDoc, protectionDocDetailsDto.IcfemIds.ToList());
     await ApplyIpcIds(protectionDoc, protectionDocDetailsDto.IpcIds.ToList(), protectionDocDetailsDto.MainIpcId);
     await ApplyProtectionDocConventionInfo(protectionDoc, protectionDocDetailsDto.RequestConventionInfoDtos);
     await UpdateBulletin(protectionDoc, protectionDocDetailsDto);
 }
        public async Task <IActionResult> Put(int id, [FromBody] ProtectionDocDetailsDto protectionDocDetailsDto)
        {
            var protectionDoc = Mapper.Map <ProtectionDoc>(protectionDocDetailsDto);
            await Executor.GetCommand <UpdateProtectionDocCommand>().Process(c => c.ExecuteAsync(id, protectionDoc));

            protectionDoc = await Executor.GetQuery <GetProtectionDocByIdQuery>().Process(q => q.ExecuteAsync(id));

            await Executor.GetHandler <UpdateProtectionDocHandler>()
            .Process(h => h.Handle(protectionDoc, protectionDocDetailsDto));

            var updatedProtectionDoc = await Executor.GetQuery <GetProtectionDocByIdQuery>().Process(q => q.ExecuteAsync(id));

            var result = Mapper.Map <ProtectionDoc, ProtectionDocDetailsDto>(updatedProtectionDoc);

            return(Ok(result));
        }
Beispiel #4
0
        private async Task ApplyProtectionDocInfo(ProtectionDocDetailsDto protectionDocDetailsDto, ProtectionDoc protectionDoc)
        {
            var protectionDocInfo = _mapper.Map <ProtectionDocDetailsDto, ProtectionDocInfo>(protectionDocDetailsDto);

            if (protectionDocInfo == null)
            {
                return;
            }
            if (protectionDoc.ProtectionDocInfo == null)
            {
                Executor.GetCommand <CreateProtectionDocInfoCommand>().Process(c => c.Execute(protectionDoc.Id, protectionDocInfo));
            }
            else
            {
                await Executor.GetCommand <UpdateProtectionDocInfoCommand>().Process(c => c.ExecuteAsync(protectionDocInfo));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] ProtectionDocDetailsDto detailDto)
        {
            var result = await _mediator.Send(new Update.Command(id, detailDto));

            return(Ok(result));
        }
        public async Task <IActionResult> Post([FromBody] ProtectionDocDetailsDto detailDto)
        {
            var result = await _mediator.Send(new Create.Command(detailDto, User.Identity.GetUserId()));

            return(Ok(result));
        }