public async Task <SubmittedNameSearchResponseDto> CreateNewNameSearchAsync(Guid user,
                                                                                    NewNameSearchRequestDto dto)
        {
            var application =
                new Application(user, EService.NameSearch, EApplicationStatus.Submitted, dto.SortingOffice);
            var nameSearch = _mapper.Map <NewNameSearchRequestDto, Fridge.Models.Main.NameSearch>(dto);

            application.NameSearch = nameSearch;
            var transaction = await _context.Database.BeginTransactionAsync();

            try
            {
                await _context.AddAsync(application);

                await _context.SaveChangesAsync();

                application.NameSearch.Reference = $"NS/{nameSearch.NameSearchId}";

                Guid payment;
                try
                {
                    payment = await _paymentsService.BillAsync(EService.NameSearch, user, nameSearch.Reference);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }

                application.Payment = payment;
                await _context.SaveChangesAsync();

                await transaction.CommitAsync();
            }
            catch (Exception e)
            {
                await transaction.RollbackAsync();

                throw;
            }

            // TODO: verify if SaveChangesSuccessful
            return(new SubmittedNameSearchResponseDto
            {
                Id = application.ApplicationId,
                NameSearch = nameSearch.NameSearchId,
                Reference = nameSearch.Reference
            });
        }
        public async Task <int> FinishApplicationAsync(Guid user, int applicationId)
        {
            var application = await GetPrivateEntityApplicationAsync(user, applicationId);

            application.PrivateEntity.Reference = "P/L: " + application.PrivateEntity.PrivateEntityId;


            Guid payment;

            try
            {
                payment = await _paymentsService.BillAsync(application.Service, application.User,
                                                           application.PrivateEntity.Reference);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            application.Payment = payment;
            application.Status  = EApplicationStatus.Submitted;
            return(await _context.SaveChangesAsync());
        }