public async Task <ProxyResponse> AddWebhookToDataBase(string jsonWebhook, int systemId)
        {
            logger.Info("WebHookReceiver UnitOfWork");

            JiraAccessService jiraAccessService = null;
            SyncSystemDTO     syncSystem        = await syncSystemBusinessService.GetSyncSystemAsync(systemId);

            if (syncSystem != null)
            {
                jiraAccessService = new JiraAccessService(syncSystem);
            }
            if (jiraAccessService == null)
            {
                //await FillWebHookEntryAsync(unitOfWork, jsonWebhook);
                logger.Error("System not found " + systemId);
                logger.Info("WebHookReceiver END");
                return(new ProxyResponse
                {
                    Result = "ok",
                    Data = "WebHookReceiver POST"
                });
            }
            List <SyncSystemFieldMapping> syncSystemFieldMappings = syncSystemFieldMappingBusinessService.GetSyncSystemFieldMappings(syncSystem.SystemId);

            logger.Info("WebHookReceiver Get Fields Start");
            customFields = await jiraAccessService.GetCustomFields();

            if (customFields == null)
            {
                logger.Error("WebHookReceiver Custom fields for system " + systemId + " is NULL!");
                logger.Info("WebHookReceiver END");
                return(new ProxyResponse
                {
                    Result = "ok",
                    Data = "WebHookReceiver POST"
                });
            }
            jiraEpicLinkField = customFields.FirstOrDefault(x => x.Name == JiraConstants.EpicLinkFieldName);

            logger.Info("WebHookReceiver Get Fields End");
            JiraRequest jiraRequest  = null;
            string      jiraEpicLink = null;
            string      jiraEpicName = null;

            try
            {
                jiraRequest = JsonConvert.DeserializeObject <JiraRequest>(jsonWebhook);
                if (jiraRequest == null)
                {
                    //await FillWebHookEntryAsync(unitOfWork, jsonWebhook);
                    logger.Info("WebHookReceiver END");
                    return(new ProxyResponse
                    {
                        Result = "ok",
                        Data = "WebHookReceiver POST"
                    });
                }
                logger.Info($"WebHookReceiver syncSystem.SystemName: {syncSystem.SystemName}; " +
                            $"jiraRequest.WebhookEvent: {jiraRequest.WebhookEvent}");

                if (jiraRequest.Issue != null)
                {
                    jiraRequest.Issue.AllFields = GetIssueFieldsDictionary(jsonWebhook);

                    if (jiraRequest.Issue.Fields.IssueType.Name != "Epic")
                    {
                        if (jiraEpicLinkField != null)
                        {
                            jiraEpicLink = (string)jiraRequest.Issue.GetField(jiraEpicLinkField.Id);
                            Master masterEpic = masterBusinessService.GetMaster(syncSystem.SystemId, jiraEpicLink);
                            if (masterEpic != null)
                            {
                                jiraEpicName = masterEpic.IssueName;
                            }
                        }
                    }
                    else
                    {
                        jiraEpicName = jiraRequest.Issue.Fields.Summary.Trim();
                    }

                    logger.Info(syncSystem.SystemName + ": " + jiraRequest.WebhookEvent
                                + "; ProjectId: " + jiraRequest.Issue.Fields.Project.Id
                                + "; ProjectKey: " + jiraRequest.Issue.Fields.Project.Key
                                + "; IssueKey: " + jiraRequest.Issue.Key
                                + "; IssueName: " + jiraRequest.Issue.Fields.Summary.Trim()
                                + "; ChangedFields: " + GetChangedFields(jiraRequest.ChangeLog?.Items));
                }
            }
            catch (Exception exception)
            {
                HandleException(exception);
            }
            jiraEpicName = jiraEpicName.RemoveNewLinesTabs().Truncate();
            //DbContextTransaction transaction = unitOfWork.BeginTransaction();
            logger.Info("WebHookReceiver DbContextTransaction");
            try
            {
                SystemToDbViewModel systemToDbViewModel = new SystemToDbViewModel();
                Staging             staging;
                MasterHistory       masterHistory;
                Master master;
                if (jiraRequest?.Issue != null)
                {
                    if (jiraRequest.WebhookEvent == "jira:issue_deleted")
                    {
                        logger.Info("WebHookReceiver END");

                        return(new ProxyResponse
                        {
                            Result = "ok",
                            Data = "WebHookReceiver POST"
                        });
                    }
                    master        = FillMasterIssueAsync(systemToDbViewModel, jiraRequest, jiraEpicLink, syncSystem);
                    masterHistory = FillMasterHistoryIssueAsync(systemToDbViewModel, jiraRequest, jiraEpicLink, syncSystem);
                    staging       = FillStagingIssueAsync(systemToDbViewModel, jiraRequest, jiraEpicLink, syncSystem,
                                                          syncSystemFieldMappings);
                    FillCustomFields(systemToDbViewModel, jiraRequest, master, staging, masterHistory,
                                     syncSystemFieldMappings, jiraEpicName);

                    AddLastUpdateUser(systemToDbViewModel, jiraRequest, staging, syncSystemFieldMappings);
                    AddSprints(systemToDbViewModel, jiraRequest, jiraAccessService, master, staging, masterHistory,
                               syncSystemFieldMappings);
                }
                if (jiraRequest?.Worklog != null)
                {
                    FillWorkLog(systemToDbViewModel, jiraRequest, systemId);
                }
                if (jiraRequest?.Version != null)
                {
                    master        = FillMasterVersionAsync(systemToDbViewModel, jiraRequest, systemId);
                    masterHistory = FillMasterHistoryVersionAsync(systemToDbViewModel, jiraRequest, systemId);
                    staging       = FillStagingVersionAsync(systemToDbViewModel, jiraRequest, systemId, syncSystemFieldMappings);

                    if (staging != null)
                    {
                        SyncSystemFieldMapping fieldMappingRecordStateGeneral = syncSystemFieldMappings
                                                                                .FirstOrDefault(x => x.SystemId == staging.SystemId &&
                                                                                                x.EpmFieldName == ProjectServerConstants.RecordStateGeneral);
                        SetCustomFields(systemToDbViewModel, fieldMappingRecordStateGeneral, master, staging, masterHistory,
                                        RecordStateConst.New, null, true);

                        SyncSystemFieldMapping fieldMappingRecordStateActual = syncSystemFieldMappings
                                                                               .FirstOrDefault(x => x.SystemId == staging.SystemId &&
                                                                                               x.EpmFieldName == ProjectServerConstants.RecordStateActual);
                        SetCustomFields(systemToDbViewModel, fieldMappingRecordStateActual, master, staging, masterHistory,
                                        RecordStateConst.Done, null, true);
                    }
                }
                await commonBusinessService.AddNewData(systemToDbViewModel);
            }
            catch (Exception exception)
            {
                logger.Error(exception);
            }
            //catch (DbUpdateException exception)
            //{
            //    foreach (DbEntityEntry dbEntityEntry in exception.Entries)
            //    {
            //        string resultString = dbEntityEntry.CurrentValues.PropertyNames.Aggregate("",
            //            (current, propertyName) =>
            //                current +
            //                $"propertyName: {propertyName} - value: {dbEntityEntry.CurrentValues[propertyName]};");
            //        logger.Fatal(
            //            $"WebHookReceiver DbUpdateException dbEntityEntry.Entity {dbEntityEntry.Entity}; resultString: {resultString}");
            //    }
            //}
            //catch (DbEntityValidationException exception)
            //{
            //    HandleException(exception);
            //    unitOfWork.RollbackTransaction(transaction);

            //    foreach (DbEntityValidationResult validationResult in exception.EntityValidationErrors)
            //    {
            //        foreach (DbValidationError error in validationResult.ValidationErrors)
            //        {
            //            HandleException(error.PropertyName + " " + error.ErrorMessage, true);
            //        }
            //    }
            //}
            //catch (Exception exception)
            //{
            //    HandleException(exception);
            //    unitOfWork.RollbackTransaction(transaction);
            //}
            ////finally
            ////{
            ////    await FillWebHookEntryAsync(unitOfWork, jsonWebhook);
            ////}
            return(new ProxyResponse
            {
                Result = "ok",
                Data = "WebHookReceiver POST"
            });
        }