public async Task <StartupResponse> UpdateAsync(int enterpriseId, int id, Domain.Models.Startup startup)
        {
            var existingEnterprise = await enterpriseRepository.FindById(enterpriseId);

            if (existingEnterprise == null)
            {
                return(new StartupResponse("Enterprise not found"));
            }

            var existingStartup = await startupRepository.FindById(id);

            if (existingStartup == null)
            {
                return(new StartupResponse("Startup not found"));
            }

            existingStartup.Name        = startup.Name;
            existingStartup.Description = startup.Description;
            existingStartup.ImageUrl    = startup.ImageUrl;

            try
            {
                startupRepository.Update(existingStartup);
                await unitOfWork.CompleteAsync();

                return(new StartupResponse(existingStartup));
            }
            catch (Exception ex)
            {
                return(new StartupResponse($"An error ocurred while updating the startup: {ex.Message}"));
            }
        }
        public async Task <StartupResponse> SaveAsync(int enterpriseId, Domain.Models.Startup startup)
        {
            var existingEnterprise = await enterpriseRepository.FindById(enterpriseId);

            if (existingEnterprise == null)
            {
                return(new StartupResponse("Enterprise not found"));
            }
            try
            {
                startup.EnterpriseId = enterpriseId;
                await startupRepository.AddAsync(startup);

                await unitOfWork.CompleteAsync();

                return(new StartupResponse(startup));
            }
            catch (Exception ex)
            {
                return(new StartupResponse($"An error ocurred while saving the startup: {ex.Message}"));
            }
        }
예제 #3
0
 public void Remove(Domain.Models.Startup startup)
 {
     _context.Startups.Remove(startup);
 }
예제 #4
0
 public void Update(Domain.Models.Startup startup)
 {
     _context.Startups.Update(startup);
 }
예제 #5
0
 public async Task AddAsync(Domain.Models.Startup startup)
 {
     await _context.Startups.AddAsync(startup);
 }