Пример #1
0
        public async Task <EnterpriseResponse> SaveAsync(int userId, Enterprise enterprise)
        {
            var existingEntrepreneur = await entrepreneurRepository.FindById(userId);

            if (existingEntrepreneur == null)
            {
                return(new EnterpriseResponse("Entrepreneur not found"));
            }
            try
            {
                enterprise.EntrepreneurId = userId;
                await enterpriseRepository.AddAsync(userId, enterprise);

                await unitOfWork.CompleteAsync();

                return(new EnterpriseResponse(enterprise));
            }
            catch (Exception ex)
            {
                return(new EnterpriseResponse($"An error ocurred while saving the enterprise: {ex.Message}"));
            }
        }