public void CanHandleNasaResponseWithNoPhotos() { var imageFileService = new ImageFileService(); var imageFileResponse = imageFileService.HandleNasaResponse(new NasaPhotoResponse()); Assert.IsNotNull(imageFileResponse); }
public ProductService(IUnitOfWork unitOfWork, ImageFileService fileService, ImageService imageService, CategoryService categoryService, BrandService brandService) { _unitOfWork = unitOfWork; _fileService = fileService; _imageService = imageService; _categoryService = categoryService; _brandService = brandService; }
public AdminController(ProductCharacteristicService productCharacteristicService, ImageFileService fileService, BrandService brandService, CategoryService categoryService, ProductService productService, ImportExportService importExportService) { _fileService = fileService; _brandService = brandService; _categoryService = categoryService; _productService = productService; _productCharacteristicService = productCharacteristicService; _importExportService = importExportService; }
public void GetFullPath_ShouldReturnFullPage() { var imageFolderPath = Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestImages"); const string filename = "myfile.jpg"; imageFileService = MockRepository.GenerateStub <ImageFileService>(); imageFileService.Expect(ifs => ifs.GetImageFolderPath()).Return(imageFolderPath); var path = imageFileService.GetFullPath(filename); var expectedPath = Path.Combine(imageFolderPath, filename); Assert.AreEqual(expectedPath, path); }
public ActionResult EfetuaCadastro(FormularioProjetoViewModel vm) { Projeto projeto = vm.Projeto; projeto.UsuarioId = User.Id; projeto.Vaga = vm.Vagas.Where(v => v.Funcao != null && v.Descricao != null).ToList(); projeto.CategoriaProjetoId = vm.IdCategoriaSelecionada; if (vm.ModoValor == FormularioProjetoViewModel.Modo.Cadastro && projetoRepository.SimpleWhere(p => p.Nome.Equals(projeto.Nome)).Count() != 0) { ModelState.AddModelError("Projeto.Nome", "Já existe um projeto com este título."); } if (projeto.Vaga.Count < 1) { ModelState.AddModelError("other", "É necessário cadastrar ao menos uma vaga."); } if (!ModelState.IsValid) { vm.Categorias = categoriaProjetoRepository.SimpleWhere(c => true); return(View("FormularioProjetoView", vm)); } if (vm.ModoValor == FormularioProjetoViewModel.Modo.Cadastro) { projetoRepository.Save(projeto); } else if (vm.ModoValor == FormularioProjetoViewModel.Modo.Alteracao) { projetoRepository.UpdateWithVagas(projeto); } if (vm.ImagemCapa != null) { ImageFileService.StoreFile(ImageType.ProjetoCapa, vm.ImagemCapa, projeto.Id); } if (vm.ImagemLogo != null) { ImageFileService.StoreFile(ImageType.ProjetoLogo, vm.ImagemLogo, projeto.Id); } TempData["mensagemRetorno"] = "Projeto " + (vm.ModoValor == FormularioProjetoViewModel.Modo.Cadastro ? "cadastrado" : "alterado") + " com sucesso!"; return(RedirectToAction("Index", "Projeto", new { Id = projeto.Id })); }
public ActionResult EfetuaCadastro(FormularioUsuarioViewModel vm) { Usuario usuario = vm.Usuario; //Bloqueando acesso para usuários não conhecidos if (!vm.Usuario.Senha.Equals("asdasd")) { TempData["mensagemRetorno"] = "O sistema não está disponível no momento para o uso geral."; return(View("FormularioUsuarioView", vm)); } if (vm.ModoValor == FormularioUsuarioViewModel.Modo.Cadastro) { usuario.Senha = LoginService.GetHash(usuario.Senha); usuarioRepository.Save(usuario); } else if (vm.ModoValor == FormularioUsuarioViewModel.Modo.Alteracao) { usuario.Senha = usuarioRepository.FindById(usuario.Id).Senha; usuarioRepository.Update(usuario); using (LoginService loginService = new LoginService()) { loginService.UpdateAuthenticationCookie(usuario); } } if (vm.ImagemPerfil != null) { ImageFileService.StoreFile(ImageType.UsuarioPerfil, vm.ImagemPerfil, usuario.Id); } if (vm.ModoValor == FormularioUsuarioViewModel.Modo.Cadastro) { TempData["mensagemRetorno"] = "Usuário cadastrado com sucesso!"; return(RedirectToAction("Index", "Autenticacao")); } else { TempData["mensagemRetorno"] = "Alterações realizadas com sucesso!"; return(RedirectToAction("Index", "BuscaProjetos")); } }
public void CanSavePhotosFromResponseToDefaultDirectory() { var photoResponse = new NasaPhotoResponse { Photos = new List <NasaPhoto> { new NasaPhoto { EarthDate = DateTime.Now, Source = "https://mars.jpl.nasa.gov/msl-raw-images/proj/msl/redops/ods/surface/sol/01000/opgs/edr/fcam/FLB_486265257EDR_F0481570FHAZ00323M_.JPG" } } }; var imageFileService = new ImageFileService(); var imageFileResponse = imageFileService.HandleNasaResponse(photoResponse); Assert.IsTrue(imageFileResponse.location.StartsWith(ImageFileService.DefaultBasePath)); }
public IHttpActionResult GetImagesByDate([FromUri] NasaPhotoRequest photoRequest) { // Check model validity if (!ModelState.IsValid) { var badRequestResponse = new BadRequest("Request is malformed", photoRequest); return(Content(HttpStatusCode.BadRequest, badRequestResponse)); } var imageRepo = new NasaPhotoRepository("https://api.nasa.gov/mars-photos/api/v1/"); // Get response from the service var response = imageRepo.Get(photoRequest); // Handle non-success states if (!response.IsSuccessful) { var responseObject = JsonConvert.DeserializeObject(response.Content); return(Content(response.StatusCode, responseObject)); } // Get an object from the response content var nasaImageResponse = JsonConvert.DeserializeObject <NasaPhotoResponse>(response.Content); // build the image path var imageFileService = new ImageFileService(photoRequest.savePath); // Get the image response try { return(Ok(imageFileService.HandleNasaResponse(nasaImageResponse))); } catch (Exception e) { var exception = new Exception("Unable to save photos. View InnerException for more details.", e); return(InternalServerError(exception)); } }
public CategoryService(IUnitOfWork unitOfWork, ImageService imageService, ImageFileService fileService) { _unitOfWork = unitOfWork; _imageService = imageService; _fileService = fileService; }
public ServiceHolder() { ImageFileService = new ImageFileService(); ImageFilterService = new ImageFilterService(); ContrastMapCalculator = new ContrastMapCalculator(); }
public NewsSaveService(IUnitOfWork unitOfWork, ImageFileService fileService, ImageService imageService) { _unitOfWork = unitOfWork; _fileService = fileService; _imageService = imageService; }