public ActionResult Create(CustomerViewModel customerViewModel) { if (!string.IsNullOrEmpty(customerViewModel.PersonalNumber)) { MrgreenCustomer mrgreenCustomer = new MrgreenCustomer { FirstName = customerViewModel.FirstName, LastName = customerViewModel.LastName, Address = customerViewModel.Address, PersonalNumber = customerViewModel.PersonalNumber }; return(RedirectToAction("Create", "MrgreenCustomer", mrgreenCustomer)); } else if (!string.IsNullOrEmpty(customerViewModel.FavoriteFootballTeam)) { RedbetCustomer redbetCustomer = new RedbetCustomer { FirstName = customerViewModel.FirstName, LastName = customerViewModel.LastName, Address = customerViewModel.Address, FavoriteFootballTeam = customerViewModel.FavoriteFootballTeam }; return(RedirectToAction("Create", "RedbetCustomer", redbetCustomer)); } ModelState.AddModelError("CustomerType", "Personal Number or Favorite Football Team should be informed"); return(View(customerViewModel)); }
public void AddCustomer(RedbetCustomer customer) { using (var httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(_redbetAdapterSettings.RedbetUrl); var json = JsonConvert.SerializeObject(customer); var stringContent = new StringContent(json, Encoding.UTF8, "application/json"); var response = httpClient.PostAsync($"api/customers/", stringContent).Result; if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) { throw new DomainException("Client can not be null."); } } }
public IActionResult Edit(RedbetCustomer redbetCustomer) { _redbetAdapter.UpdateCustomer(redbetCustomer); return(RedirectToAction("Index", "Customer")); }
//[HttpPost] public IActionResult Create(RedbetCustomer redbetCustomer) { _redbetAdapter.AddCustomer(redbetCustomer); return(RedirectToAction("Index", "Customer")); }