Example #1
0
        public async Task <IActionResult> Edit(int id, Broker broker)
        {
            if (ModelState.IsValid)
            {
                UpdateBrokerViewModel viewModel = new UpdateBrokerViewModel()
                {
                    Phone             = broker.Phone,
                    Name              = broker.Name,
                    Email             = broker.Email,
                    ResponsibleBroker = broker.ResponsibleBroker,

                    CEP          = broker.CEP,
                    Street       = broker.Street,
                    Neighborhood = broker.Neighborhood,
                    UF           = broker.UF,
                    City         = broker.City,
                    Number       = broker.Number
                };

                if (await _movtechAPIService.AtualizarCorretora(broker.Id, viewModel))
                {
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    ModelState.AddModelError("", "Não Foi possível Atualizar a Corretora");
                    return(View(broker));
                }
            }
            else
            {
                return(View(broker));
            }
        }