Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("LojaId,Nome,cnpj,NomeFantasia,ShoppingId")] LojaModel lojaModel)
        {
            if (id != lojaModel.LojaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var currentUser = await _userManager.GetUserAsync(User);

                if (currentUser == null)
                {
                    return(Unauthorized());
                }

                lojaModel.OwnerId = currentUser.Id;

                await _repositoryLoja.UpdateAsync(id, lojaModel);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ShoppingId"] = new SelectList(await _repositoryLoja.GetAllAsync(), "ShoppingId", "Nome", lojaModel.ShoppingId);
            return(View(lojaModel));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("EstadoId,Nome")] EstadoModel estadoModel)
        {
            if (id != estadoModel.EstadoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _repositoryEstado.UpdateAsync(id, estadoModel);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(estadoModel));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("CidadeId,Nome,EstadoId")] CidadeModel cidadeModel)
        {
            if (id != cidadeModel.CidadeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _repositoryCidade.UpdateAsync(id, cidadeModel);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EstadoId"] = new SelectList(_repositoryEstado.GetAll(), "EstadoId", "Nome");
            return(View(cidadeModel));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ShoppingId,Nome,CNPJ,Email,EnderecoId")] ShoppingModel shoppingModel)
        {
            if (id != shoppingModel.EnderecoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _repositoryShopping.UpdateAsync(id, shoppingModel);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EnderecoId"] = new SelectList(_repositoryEndereco.GetAll(), "EnderecoId", "Rua");
            return(View(shoppingModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ClienteId,Nome,Cpf,EnderecoId")] ClienteModel clienteModel)
        {
            if (id != clienteModel.ClienteId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _repositoryCliente.UpdateAsync(id, clienteModel);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EnderecoId"] = new SelectList(_repositoryEndereco.GetAll(), "EnderecoId", "Rua");
            return(View(clienteModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("EnderecoId,Rua,Numero,Bairro,Complemento,Cep,CidadeId")] EnderecoModel enderecoModel)
        {
            if (id != enderecoModel.EnderecoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _repositoryEndereco.UpdateAsync(id, enderecoModel);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CidadeId"] = new SelectList(_repositoryCidade.GetAll(), "CidadeId", "Nome");
            return(View(enderecoModel));
        }