public ActionResult Edit(int id, CarrierPhoneNumberViewModel carrierPhoneNumber) { if (ModelState.IsValid) { var carrierPhoneNumberDomain = _mapper.Map <CarrierPhoneNumberViewModel, CarrierPhoneNumber>(carrierPhoneNumber); _appCarrierPhoneNumber.Update(carrierPhoneNumberDomain); TempData["msg"] = "Registro alterado com sucesso."; return(Redirect(string.Format("/Transportadora?id={0}", carrierPhoneNumber.CarrierId))); } TempData["error"] = "Falha ao alterar o registro."; return(View(carrierPhoneNumber)); }
public ActionResult Create(int carrierId) { var carrier = _appCarrier.GetById(carrierId); if (carrier.Id == 0) { return(Redirect("/Encontrar-Transportadora")); } var carrierViewModel = _mapper.Map <Carrier, CarrierViewModel>(carrier); var carrierPhoneNumberViewModel = new CarrierPhoneNumberViewModel { CarrierId = carrierId, Carrier = carrierViewModel }; return(View(carrierPhoneNumberViewModel)); }