public async Task <OperationResult> Update(TrashInspectionModel updateModel) { var selectedTrashInspection = new Microting.eFormTrashInspectionBase.Infrastructure.Data.Entities.TrashInspection { Id = updateModel.Id, Date = updateModel.Date, EakCode = updateModel.EakCode, InstallationId = updateModel.InstallationId, MustBeInspected = updateModel.MustBeInspected, Producer = updateModel.Producer, RegistrationNumber = updateModel.RegistrationNumber, Time = updateModel.Time, Transporter = updateModel.Transporter, TrashFraction = updateModel.TrashFraction, WeighingNumber = updateModel.WeighingNumber, Status = updateModel.Status, Version = updateModel.Version, WorkflowState = updateModel.WorkflowState, ExtendedInspection = updateModel.ExtendedInspection, InspectionDone = updateModel.InspectionDone }; await selectedTrashInspection.Update(_dbContext); return(new OperationResult(true)); }
#pragma warning disable 1998 public async Task Handle(TrashInspectionDeleted message) { try { TrashInspectionModel createModel = message.TrashInspectionModel; List <TrashInspectionCase> trashInspectionCases = _dbContext.TrashInspectionCases .Where(x => x.TrashInspectionId == createModel.Id).ToList(); foreach (TrashInspectionCase trashInspectionCase in trashInspectionCases) { bool result = await _core.CaseDelete(int.Parse(trashInspectionCase.SdkCaseId)); if (result) { await trashInspectionCase.Delete(_dbContext); } } Microting.eFormTrashInspectionBase.Infrastructure.Data.Entities.TrashInspection trashInspection = await _dbContext.TrashInspections.SingleAsync(x => x.Id == createModel.Id); trashInspection.InspectionDone = true; await trashInspection.Update(_dbContext); if (message.ShouldDelete) { await trashInspection.Delete(_dbContext); } } catch (Exception exception) { Console.WriteLine(exception.Message); } }