public async Task <IActionResult> Post([FromBody] ShipAddress value) { string userID = HttpContext.User.Identity.Name; int count = await _shipAddressRepository.AddAsync(value); return(Ok(value.AddressID)); }
public async Task <IActionResult> Create([Bind("AddressID,Address,City,PhoneNumber,Province,Receiver,UserID,ZipCode")] ShipAddress shipAddress) { if (ModelState.IsValid) { string temp = string.Empty; temp = Request.Form["dpProvince"].ToString(); int provinceID = 0; int cityID = 0; int.TryParse(temp, out provinceID); shipAddress.Province = await _addressRepository.GetProvinceNameAsync(provinceID); temp = Request.Form["dpProvince"].ToString(); int.TryParse(temp, out cityID); shipAddress.City = await _addressRepository.GetCityNameAsync(cityID); shipAddress.UserID = HttpContext.User.Identity.Name; int count = await _addressRepository.AddAsync(shipAddress); return(RedirectToAction("Index")); } return(View(shipAddress)); }