Exemple #1
0
        public IActionResult CreateOrEdit(CategoryViewModel viewModel)
        {
            if (!string.IsNullOrEmpty(viewModel.Name))
            {
                _categoryStorer.Store(viewModel.Id, viewModel.Name);
            }

            return(View());
        }
Exemple #2
0
        public void Should_Store_Category()
        {
            var categoryDto = new CategoryDto {
                name = "name"
            };

            var categoryRepository = new Mock <ICategoryRepository>();
            var categoryStorer     = new CategoryStorer(categoryRepository.Object);

            categoryStorer.Store(categoryDto);

            categoryRepository.Verify(r => r.Add(It.Is <Category>(c => c.Name.Equals(categoryDto.name))));
        }
Exemple #3
0
        public IActionResult CreateOrEdit(CategoryViewModel viewModel)
        {
            //jeito velho de fazer, instanciando a classe
            //jeito novo de fazer,  injecao de dependencia
            //passar a classe CategoryStorer injetada no construtor desta classe
            //E consequente o repositorio tambem sera passar para o construtor
            //para que seja feita a injecao de dependencias tem que configurar os servicos
            //a injecao de depencia se encontra no projeto DI

            /*var repositorio = new repositorio();
             * var storer = new CategoryStorer();*/

            _categoryStorer.Store(viewModel.Id, viewModel.Name);

            return(RedirectToAction("Index"));
        }
Exemple #4
0
 public IActionResult CreateOrEdit(CategoryViewModel viewModel)
 {
     _categoryStorer.Store(viewModel.Id, viewModel.Name);
     return(View());
 }
 public IActionResult CreateOrEdit(CategoryViewModel dto)
 {
     _categoryStorer.Store(dto.Id, dto.Name);
     return(RedirectToAction("Index"));
 }
 public IActionResult CreateOrEdit(CategoryViewModel viewModelo)
 {
     _categoryStorer.Store(viewModelo.Id, viewModelo.Name);
     return(Redirect("Index"));// View();
 }
Exemple #7
0
 public IActionResult CreateOrEdit(int id, string name)
 {
     _categoryStorer.Store(id, name);
     return(View());
 }
Exemple #8
0
 public IActionResult CreateOrEdit(CategoryDto dto)
 {
     _categoryStorer.Store(dto);
     return(View());
 }
Exemple #9
0
 public IActionResult CreateOrEdit(CategoryViewModel category)
 {
     _caregoryStorer.Store(category.Id, category.Name);
     return(View());
 }