public async Task <ResultCrmDb> AddRoleForLevelOrgAsync(RoleCreateArgs args) { var result = new ResultCrmDb(); try { if ((await _crmDbContext.UserRole.FirstOrDefaultAsync(r => r.LevelOrgId == args.IdLevelorg & r.Name == args.CaptionRole)) != null) { result.AddError("", "Такая роль уже существует!"); return(result); } var role = new UserRole(); role.LevelOrgId = args.IdLevelorg; role.Name = args.CaptionRole; role.Sysname = args.CaptionRole; await _crmDbContext.UserRole.AddAsync(role); await _crmDbContext.SaveChangesAsync(); } catch (Exception e) { result.AddError("", e.Message); } return(result); }
public async Task <IHttpActionResult> PutAlter(int id, AlterReport alterReport) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != alterReport.Id) { return(BadRequest()); } db.Entry(alterReport).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlterReportExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private async Task <ResultCrmDb> AddOrEditModel <TModel, TModelEdit>(TModelEdit modelDto, DbSet <TModel> models) where TModel : BaseModel where TModelEdit : IBaseModel { var result = new ResultCrmDb(); try { var model = await models.FirstOrDefaultAsync(f => f.Id == modelDto.Id); model = modelDto.Map(model); if (model.Id == 0) { _reportDbContext.Add(model); } else { _reportDbContext.Update(model); } await _reportDbContext.SaveChangesAsync(); } catch (Exception e) { Console.WriteLine(e); result.AddError(ErrorCode.NoCode.ToString(), e.Message); } return(result); }
public async Task <IActionResult> Create([Bind("UtilajModelID,Utilaj,ZonaUtilaj")] UtilajModel utilajModel) { if (ModelState.IsValid) { _context.Add(utilajModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(utilajModel)); }
public async Task <IActionResult> Create([Bind("TipAbonamentModelID,Denumire,NrTotalSedinte,IsPersonalTraining,Pret")] TipAbonamentModel tipAbonamentModel) { if (ModelState.IsValid) { _context.Add(tipAbonamentModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tipAbonamentModel)); }
public async Task <IActionResult> Create([Bind("AntrenamentModelID,Data,OraStart,OraStop,IsPersonalTraining,Grupa")] AntrenamentModel antrenamentModel) { if (ModelState.IsValid) { _context.Add(antrenamentModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(IndexZilnic))); } return(View(antrenamentModel)); }
public async Task <IActionResult> Create([Bind("ResponsabilModelID,Nume,Prenume,Email,Functie,Departament")] ResponsabilModel responsabilModel) { if (ModelState.IsValid) { _context.Add(responsabilModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(responsabilModel)); }
/// <summary> /// Генерация полей для режима на основании схемы БД /// </summary> /// <param name="formModelId"></param> /// <returns></returns> public async Task GenerateField(int formModelId) { var formModel = await _reportDbContext.FormModel.FirstOrDefaultAsync(f => f.Id == formModelId); if (formModel == null) { return; } if (formModel.TableName == null) { throw new UserMessageException("Не удалось определить таблицу"); } using (MySqlConnection connection = new MySqlConnection(_dataBaseMain.ConntectionString)) { int i = 10; var reuslt = await connection.QueryAsync <ColumnTable>(string.Format(SelectField, connection.Database, formModel.TableName)); foreach (var columnTable in reuslt) { var field = await _reportDbContext.Field.FirstOrDefaultAsync(f => f.FormModelId == formModel.Id && f.Name == columnTable.ColumnName); if (field != null) { continue; } field = new Field(); field.Name = columnTable.ColumnName; field.FormModel = formModel; field.MaxLength = columnTable.Maxlength; field.Order = i; field.OrderDetail = i; field.DisplayName = columnTable.ColumnName; field.TypeControl = GetTypeControl(columnTable.DataType); field.TypeField = TypeField.ListAndEdit; field.DefaultTypeAccec = TypeAccec.Full; field.IsKey = !string.IsNullOrEmpty(columnTable.ColumnKey); field.IsVisibleList = false; field.WidthList = 20; field.IsDetail = true; field.TypeGroup = TypeGroup.None; i = i + 10; _reportDbContext.Add(field); } await _reportDbContext.SaveChangesAsync(); } }
public async Task HandleAsync(AddEditDivisionWeeklyReportCommand request) { var statuses = request.DivisionProjectStatuses.ToList(); if (!statuses.Any()) { return; } var yearWeek = statuses.First().YearWeek; var listProjectId = statuses.Select(s => s.ProjectId); var projects = (await _dbContext.Projects .Where(p => listProjectId.Contains(p.Id)) .Select(p => new { Project = p, Statuses = p.DivisionProjectStatuses.Where(d => d.YearWeek == yearWeek) }) .ToListAsync()).Select(p => p.Project).ToList(); projects.ForEach(p => { var dto = statuses.First(s => s.ProjectId == p.Id); var status = new DivisionProjectStatus(dto.StatusId, yearWeek, dto.ProjectId, dto.StatusColor, dto.ProjectStatus, dto.Actions); p.AddEditDivisionStatus(status); }); await _dbContext.SaveChangesAsync(); request.Response = 1; }
public async Task HandleAsync(EditMetricsCommand request) { var metricDtos = request.MetricGroups.SelectMany(g => g.Metrics, (g, m) => { m.Tool = g.Tool; m.ToolOrder = g.ToolOrder; return(m); }).ToList(); var listMetricId = metricDtos.Select(m => m.Id).ToList(); var metricsInDb = _dbContext.Metrics.Include(m => m.Thresholds).Where(m => listMetricId.Contains(m.Id)).ToList(); metricDtos.ForEach(dto => { var metric = metricsInDb.First(m => m.Id == dto.Id); metric.UpdateValue(dto.Id, dto.Name, dto.ValueType, dto.Unit, dto.Tool, dto.SelectValues, dto.Order, dto.ToolOrder); var thresholdsToUpdate = dto.Thresholds.Select(t => new Threshold(t.MetricStatusId, t.MetricId, t.UpperBound, t.LowerBound, t.UpperBoundOperator, t.LowerBoundOperator, t.IsRange, t.Value)).ToList(); metric.ReplaceThresholds(thresholdsToUpdate); }); await _dbContext.SaveChangesAsync(); request.Response = 1; }
public async Task HandleAsync(AddProjectCommand request) { using (var transaction = await _dbContext.Database.BeginTransactionAsync()) { try { var userRoleList = await _mediator.SendAsync(new GetListUserRoleQuery()); var project = _mapper.Map <ProjectProxy>(request); project.CreatedDate = DateTime.Now; await _dbContext.Projects .AddAsync(_mapper.Map <Project>(project, opts => { opts.Items[MiscHelper.UserRoleListCtor] = userRoleList; })); await _dbContext.SaveChangesAsync(); await transaction.CommitAsync(); request.Response = project.Id; } catch (Exception) { await transaction.RollbackAsync(); throw; } } }
public async Task <ResultCrmDb> EditAccessAsync(int idRole, ItemAccess[] items) { var result = new ResultCrmDb(); try { foreach (var btn in items.Where(x => x.IsBtn == true)) { var updated = await _crmDbContext.AccessForm.FirstOrDefaultAsync(x => x.UserRoleId == idRole& x.FormModelId == btn.FormId& x.ButtonFormId == btn.BtnId); if (updated != null) { updated.TypeAccec = btn.typeAccess; _crmDbContext.AccessForm.Update(updated); } else { var access = new AccessForm() { ButtonFormId = btn.BtnId, UserRoleId = idRole, FormModelId = btn.FormId, TypeAccec = btn.typeAccess }; await _crmDbContext.AccessForm.AddAsync(access); } } await _crmDbContext.SaveChangesAsync(); } catch (Exception e) { result.AddError("", e.Message); } return(result); }
public async Task <IActionResult> Create([Bind("PersoanaModelID,Nume,Prenume,Email,Telefon,DataNastere,Sex,IsAcordGDPR")] PersoanaModel persoanaModel) { if (ModelState.IsValid) { PersoanaModel isRegistredPers = _context.PersoanaModels.FirstOrDefault(pers => pers.Email == persoanaModel.Email); if (isRegistredPers != null) { ModelState.AddModelError($"User:"******"Email inregistrat pe numele {isRegistredPers.NumeComplet}"); return(View(persoanaModel)); } _context.Add(persoanaModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(persoanaModel)); }
public async Task <ActionResult> DeleteConfirmed(int id) { AlterReport alterReport = await db.Alters.FindAsync(id); db.Alters.Remove(alterReport); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task HandleAsync(RemoveMetricsCommand request) { var metricsToRemove = _dbContext.Metrics.Where(m => m.Tool == request.Tool); _dbContext.Metrics.RemoveRange(metricsToRemove); await _dbContext.SaveChangesAsync(); request.Response = 1; }
public async Task HandleAsync(RemoveMetricCommand request) { var metric = await _dbContext.Metrics.FirstAsync(m => m.Id == request.MetricId); _dbContext.Metrics.Remove(metric); await _dbContext.SaveChangesAsync(); request.Response = 1; }
public async Task HandleAsync(AddMetricCommand request) { var metric = _mapper.Map <Metric>(request.Metric); await using (var transaction = await _dbContext.Database.BeginTransactionAsync()) { await _dbContext.Metrics.AddAsync(metric); await _dbContext.SaveChangesAsync(); metric.ReplaceThresholds(metric.Thresholds.ToList()); await _dbContext.SaveChangesAsync(); await transaction.CommitAsync(); } request.Response = metric.Id; }
public async Task <ResultCrmDb> AddAsync(LevelOrgAddArgs args) { var result = new ResultCrmDb(); var toAdd = new t_levelorg(); try { var org = await _crmDbContext.t_levelorg.FirstOrDefaultAsync(r => r.Inn == args.Inn& r.Kpp == args.Kpp& r.Oktmo == args.Oktmo); if (org != null) { result.AddError("", "Организация с такими ИНН, КПП, ОКТМО уже существует!"); return(result); } var l = _crmDbContext.t_levelorg.Count(); toAdd = args; if (toAdd.Parent == null || toAdd.Parent == 0) { if (await _crmDbContext.t_levelorg.FirstOrDefaultAsync(f => f.Parent == null || f.Parent == 0) != null) { throw new Exception("Не возможно иметь 2 основных уровня levelorg"); } else { if (_crmDbContext.t_levelorg.Count() != 0) { if (await _crmDbContext.t_levelorg.FirstOrDefaultAsync(f => toAdd.Parent.ToString() == f.Sysid.ToString()) == null) { throw new Exception("Не существует родительской записи для levelorg"); } } } } await _crmDbContext.t_levelorg.AddAsync(toAdd); await _crmDbContext.SaveChangesAsync(); } catch (Exception e) { result.AddError("", e.Message); } return(result); }
public async Task <IActionResult> Create([Bind("ActiuneModelID,Descriere,Tip,IsUseInputText,InputText,UtilajModelID")] ActiuneModel actiuneModel) { ViewData["UtilajModelID"] = new SelectList(_context.UtilajModels, "UtilajModelID", "Utilaj", actiuneModel.UtilajModelID); try { if (ModelState.IsValid) { _context.Add(actiuneModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch { return(View(actiuneModel)); } return(View(actiuneModel)); }
public async Task HandleAsync(AddEditDoDReportLinkCommand request) { var dodRecords = await _dbContext.DoDReports.Where(d => d.ProjectId == request.ProjectId& d.YearWeek == request.YearWeek).ToListAsync(); dodRecords.ForEach(r => r.SetReportFile(request.ReportFileName, request.LinkToReport)); await _dbContext.SaveChangesAsync(); request.Response = 1; }
public async Task HandleAsync(RemoveProjectCommand request) { var project = new Project(); // Set project Id with Reflection project.GetType().GetProperty("_id").SetValue(project, request.ProjectId); _dbContext.Projects.Remove(project); await _dbContext.SaveChangesAsync(); request.Response = 1; }
public async Task <IActionResult> Create([Bind("ProblemaModelID,DataIntroducere,UtilajModelID,ProblemaDescriere,ComentariuMentenanta,LastPersonUpdateRow")] ProblemaModel problemaModel) { if (ModelState.IsValid) { problemaModel.ComentariuMentenanta = "-"; problemaModel.Stare = Status.Nerezolvat; _context.Add(problemaModel); await _context.SaveChangesAsync(); // Send Mail string filePathMailModel = Path.Combine(_env.WebRootPath, "Fisiere\\MailDate.JSON"); MailModel mailModel = _emailSender.GetMailModelAsync(filePathMailModel).Result; UtilajModel utilajName = _context.UtilajModels.FirstOrDefault(utilaj => utilaj.UtilajModelID == problemaModel.UtilajModelID); await _emailSender.SendEmailAsync(mailModel.FromAdress, mailModel.ToAddress, mailModel.Subjsect, problemaModel.LastPersonUpdateRow + mailModel.Messaege + problemaModel.ProblemaDescriere + $" la utilajul: {utilajName.Utilaj}"); return(RedirectToAction(nameof(Index))); } ViewData["ResponsabilModelID"] = new SelectList(_context.ResponsabilModel, "ResponsabilModelID", "Email", problemaModel.ResponsabilModelID); ViewData["UtilajModelID"] = new SelectList(_context.UtilajModels, "UtilajModelID", "Utilaj", problemaModel.UtilajModelID); return(View(problemaModel)); }
public async Task <ResultCrmDb> EditAccessAsync(int idRole, ItemAccess[] items) { var result = new ResultCrmDb(); try { var it = items.Where(x => x.IsForm == true); var ac = _crmDbContext.AccessForm.ToList(); foreach (var forms in items.Where(x => x.IsForm == true)) { var updated = await _crmDbContext.AccessForm.Where(x => x.UserRoleId == idRole).Where(x => x.ButtonFormId == null).Where(x => x.FieldId == null).FirstOrDefaultAsync(x => x.FormModelId == forms.FormId); var updated1 = _crmDbContext.AccessForm.Where(x => x.UserRoleId == idRole & (x.FormModelId == forms.FormId) & (x.ButtonFormId == null) & (x.FieldId == null)).FirstOrDefault(); if (updated != null) { updated.TypeAccec = forms.typeAccess; _crmDbContext.AccessForm.Update(updated); await _crmDbContext.SaveChangesAsync(); } else { var access = new AccessForm() { UserRoleId = idRole, FormModelId = forms.FormId, TypeAccec = forms.typeAccess }; await _crmDbContext.AccessForm.AddAsync(access); await _crmDbContext.SaveChangesAsync(); } } } catch (Exception e) { result.AddError("", e.Message); } return(result); }
/// <summary> /// Регистрация пользователя в БД CRM /// </summary> /// <param name="registration"></param> /// <param name="userManager"></param> /// <returns></returns> public async Task <ResultCrmDb> RegistrationUser(RegistrationUserArgs registration, string userManager) { var result = new ResultCrmDb(); var userManagerId = await _crmDbContext.User.Where(f => f.Account == userManager).FirstOrDefaultAsync(); var typeUserId = await _crmDbContext.TypeUser.Where(s => s.Sysname == "PLAYER").FirstOrDefaultAsync(); var countUser = await _crmDbContext.User.CountAsync(c => c.Account.ToLower() == registration.Account.ToLower()); if (countUser > 0) { result.Succeeded = false; result.AddError("crm001", "Пользователь с таким логином уже существует"); return(result); } var user = new User(); user.Account = registration.Account; user.Email = registration.Email; user.Name = registration.Name; user.Surname = registration.Surname; user.Middlename = registration.Middlename; user.TypeUser = typeUserId; _crmDbContext.User.Add(user); await _crmDbContext.SaveChangesAsync(); result.Succeeded = true; return(result); }
// Populate Plcs DbContext and redirect to action with parameter public async Task <IActionResult> PopulatePlcDb() { if (_context.Plcs.ToList() == null) { _context.Plcs.AddRange( new PlcModel { Name = "Plc 1", Ip = "192.168.0.1", IsEnable = true, DataCreation = DateTime.Now, PingRequestsFail = 3, Rack = 1, Slot = 1 }, new PlcModel { Name = "Plc 2", Ip = "192.168.0.2", IsEnable = true, DataCreation = DateTime.Now, PingRequestsFail = 3, Rack = 1, Slot = 1 }, new PlcModel { Name = "Plc 3", Ip = "192.168.0.3", IsEnable = true, DataCreation = DateTime.Now, PingRequestsFail = 3, Rack = 1, Slot = 1 }, new PlcModel { Name = "Plc 4", Ip = "192.168.0.4", IsEnable = true, DataCreation = DateTime.Now, PingRequestsFail = 3, Rack = 1, Slot = 1 }, new PlcModel { Name = "Plc 5", Ip = "192.168.0.5", IsEnable = true, DataCreation = DateTime.Now, PingRequestsFail = 3, Rack = 1, Slot = 1 }, new PlcModel { Name = "Plc 6", Ip = "192.168.0.6", IsEnable = true, DataCreation = DateTime.Now, PingRequestsFail = 3, Rack = 1, Slot = 1 } ); } await _context.SaveChangesAsync(); List <PlcModel> plcs = await _context.Plcs.ToListAsync(); // Redirect to Action with a anonimous parameter // nu se poate transmite un obiect complex in redirectto action, deoarece urlul ar fi prea lung, poti trimite doar variablie basic: int, string ... // transmitem obiect complex prin: Temp data TempData["list"] = JsonSerializer.Serialize(plcs); return(RedirectToAction("IndexPlc", "Test", new { nume = "Nume din populate PLC DB", numar = 3333 })); }
public async Task HandleAsync(ReportCreated _event, ICorrelationContext context) { var report = await _dbContext.Reports.FindAsync(_event.Id); try { var location = await _locationHttpService.GetLocationAsync(report.LocationId); var locations = await _locationHttpService.GetLocationsByNameAsync(location.LocationName); var phoneNumbers = new List <Phone>(); foreach (var locationItem in locations) { phoneNumbers.AddRange(await _personHttpService.GetPhoneNumbersByPersonIdAsync(locationItem.PersonId)); } report.LocationName = location.LocationName; report.PersonCount = locations.Select(l => l.PersonId).Distinct().Count(); report.PhoneNumberCount = phoneNumbers.Select(p => p.PhoneNumber).Distinct().Count(); report.Status = Data.Entity.ReportStatus.Completed; report.UpdateDate = DateTime.Now; await _dbContext.SaveChangesAsync(); _logger.LogInformation($"[Local Transaction] : Report completed. CorrelationId: {context.CorrelationId}"); } catch (Exception ex) { report.Status = Data.Entity.ReportStatus.Failed; report.UpdateDate = DateTime.Now; await _dbContext.SaveChangesAsync(); _logger.LogInformation($"[Local Transaction] : Report failed. CorrelationId: {context.CorrelationId}"); throw ex; } }
public async Task <IActionResult> Create([Bind("AbonamentModelID,DataStart,TipAbonamentModelID,PersoanaModelID")] AbonamentModel abonamentModel) { ViewData["TipAbonamentModelID"] = new SelectList(_context.TipAbonamentModels, "TipAbonamentModelID", "Denumire", abonamentModel.TipAbonamentModelID); ViewData["PersoanaModelID"] = new SelectList(_context.PersoanaModels, "PersoanaModelID", "NumeComplet", abonamentModel.PersoanaModelID); if (ModelState.IsValid) { TipAbonamentModel tipAb = _context.TipAbonamentModels.FirstOrDefault(a => a.TipAbonamentModelID == abonamentModel.TipAbonamentModelID); abonamentModel.DataStop = abonamentModel.DataStart.AddDays(31); abonamentModel.StareAbonament = StareAbonament.Activ; abonamentModel.NrSedinteEfectuate = 0; if (tipAb.NrTotalSedinte == 1) // Daca facem 1 abonament cu o singura sedinta il incheiem pe loc, nu mai e nevoie // sa il incheiem din antrenament { abonamentModel.DataStop = abonamentModel.DataStart; abonamentModel.StareAbonament = StareAbonament.Finalizat; abonamentModel.NrSedinteEfectuate = 1; } // Daca persoana nu are atrenament Finalizat nu putem sa o adaugam pe un alt abonament AbonamentModel isAbExpiredPers = _context.AbonamentModels.Include(p => p.PersoanaModel) .Include(t => t.TipAbonament).FirstOrDefault(ab => ab.PersoanaModelID == abonamentModel.PersoanaModelID); List <AbonamentModel> listOfAbForThisPerson = _context.AbonamentModels.Include(p => p.PersoanaModel).Include(t => t.TipAbonament).Where(ab => ab.PersoanaModelID == abonamentModel.PersoanaModelID).ToList(); isAbExpiredPers = listOfAbForThisPerson.LastOrDefault(); if (isAbExpiredPers != null) { if (isAbExpiredPers.StareAbonament == StareAbonament.Activ || isAbExpiredPers.StareAbonament == StareAbonament.Extins) { ModelState.AddModelError($"User:"******"{isAbExpiredPers.PersoanaModel.NumeComplet} are abonament: {isAbExpiredPers.StareAbonament} si expira pe: " + isAbExpiredPers.DataStop.ToString("dd.MM.yyyy")); return(View(abonamentModel)); } } _context.Add(abonamentModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(abonamentModel)); }
public async Task <ResultCrmDb> RegisterUserAsync(RegistrationUserArgs args) { var result = new ResultCrmDb(); var errors = 0; List <string> textErrors = new List <string>(); try { if (string.IsNullOrWhiteSpace(args.Account)) { textErrors.Add("аккаунт пользователя не указан"); errors++; } if (string.IsNullOrWhiteSpace(args.Surname)) { textErrors.Add("Фамилия пользователя не указана"); errors++; } if (errors > 0) { throw new Exception(); } var countUser = await _crmDbContext.User.CountAsync(c => c.Account.ToLower() == args.Account.ToLower()); if (countUser > 0) { textErrors.Add("пользователь с таким логином уже существует"); errors++; } var user = new User(); user.Account = args.Account; user.Email = args.Email; user.Phone = args.Phone; user.Name = args.Name; user.Surname = args.Surname; user.Middlename = args.Middlename; await _crmDbContext.User.AddAsync(user); await _crmDbContext.SaveChangesAsync(); } catch (Exception e) { var err = ""; if (errors > 0) { err = string.Join(",\n", textErrors.ToArray()); } else { err = e.Message; } var patternError = $"Ошибка регистрации пользователя:\n {err}."; result.AddError("", $"{patternError}"); } return(result); }
public async Task HandleAsync(EditDoDReportCommand request) { if (request.DodReports.Count < 1) { return; } var projectId = request.DodReports[0].ProjectId; var yearWeek = request.DodReports[0].YearWeek; var listMetricId = request.DodReports.Select(d => d.MetricId).Distinct(); var project = await _dbContext.Projects.FirstAsync(p => p.Id == projectId); var listMetric = await _dbContext.Metrics.Where(m => listMetricId.Contains(m.Id)) .ToListAsync(); request.DodReports.ForEach(d => { d.Project = project; d.Metric = listMetric.First(m => m.Id == d.MetricId); }); var dodReportsInDb = await _dbContext.DoDReports .AsNoTracking() .Where(r => r.ProjectId == projectId && r.YearWeek == yearWeek) .ToListAsync(); var dodReports = request.DodReports.Select(d => new DoDReport(d.ProjectId, d.Value, d.YearWeek, d.MetricId, d.ReportFileName, d.LinkToReport, d.Metric, d.Project)).ToList(); var recordsToAdd = dodReports.Except(dodReportsInDb, DoDReport.DoDComparer); var recordsToRemove = dodReportsInDb.Except(dodReports, DoDReport.DoDComparer); var recordsToUpdate = dodReports.Intersect(dodReportsInDb, DoDReport.DoDComparer); await _dbContext.DoDReports.AddRangeAsync(recordsToAdd); _dbContext.DoDReports.RemoveRange(recordsToRemove); _dbContext.UpdateRange(recordsToUpdate); await _dbContext.SaveChangesAsync(); request.Response = 1; }
public async Task HandleAsync(CreatePersonReportsByLocationCommand command, ICorrelationContext context) { var report = new Report { Status = ReportStatus.Created, Id = Guid.NewGuid(), PersonId = command.PersonId, LocationId = command.LocationId, PersonCount = 0, PhoneNumberCount = 0, Name = typeof(CreatePersonReportsByLocationCommand).Name }; _dbContext.Reports.Add(report); await _dbContext.SaveChangesAsync(); _logger.LogInformation($"[Local Transaction] : Report is creating... CorrelationId: {context.CorrelationId}"); await _busPublisher.PublishAsync(new ReportCreated(report.Id, personId : command.PersonId, locationId : command.LocationId), context); }