public IActionResult Create(BarberCreateViewModel barberCreateViewModel) { var json = JsonConvert.SerializeObject(barberCreateViewModel); var data = new StringContent(json, Encoding.UTF8, "application/json"); var result = _client.PostAsync("api/barbers", data).Result; if (result.StatusCode == System.Net.HttpStatusCode.OK) { return(Redirect("/site/vertical/table-barber.html")); } return(Redirect("/site/vertical/create-barber.html")); }
public ActionResult Create([Bind(Include = "Id,Name,WorkDayStart,WorkDayEnd")] BarberCreateViewModel barberCreateViewModel) { if (ModelState.IsValid) { var barber = _mapper.Map <Barber>(barberCreateViewModel); barber.Account = _repositoryAccount.Get(barberCreateViewModel.AccountId); barber.Branch = _repositoryBranch.Get(barberCreateViewModel.BranchId); _repositoryBarber.Add(barber); return(RedirectToAction("Index")); } return(View(barberCreateViewModel)); }