public ActionResult UpdateOrderAddress(ViewModel theModel) { var _Validator = new UpdateOrderAddressValidatorDto(); var ReturnFileName = ""; var _UpdateOrderAddressData = new UpdateOrderAddressDto(); _UpdateOrderAddressData.AddressLine1 = theModel.AddressLine1; _UpdateOrderAddressData.Locality = theModel.Locality; _UpdateOrderAddressData.Postcode = theModel.Postcode; _UpdateOrderAddressData.VerserOrderID = theModel.VerserOrderID; _UpdateOrderAddressData.State = theModel.State; ValidationResult result = _Validator.Validate(theModel); if (!result.IsValid) { foreach (ValidationFailure failure in result.Errors) { ModelState.AddModelError(failure.PropertyName, failure.ErrorMessage); } } else { ReturnFileName = Helper.Helper.UpdateOrderAddress(_UpdateOrderAddressData); if (ReturnFileName != null) { ReturnFileName = ReturnFileName.Trim('"'); TempData["ValidationErrors"] = ReturnFileName; } } return(Json(ReturnFileName, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdateOrderAddress(ViewModel theModel) { var _Validator = new UpdateOrderAddressValidatorDto(); var _UpdateOrderAddressData = new UpdateOrderAddressDto(); _UpdateOrderAddressData.AddressLine1 = theModel.AddressLine1; _UpdateOrderAddressData.Locality = theModel.Locality; _UpdateOrderAddressData.Postcode = theModel.Postcode; _UpdateOrderAddressData.VerserOrderID = theModel.VerserOrderID; _UpdateOrderAddressData.State = theModel.State; ValidationResult result = _Validator.Validate(theModel); if (!result.IsValid) { foreach (ValidationFailure failure in result.Errors) { ModelState.AddModelError(failure.PropertyName, failure.ErrorMessage); } } else { var ReturnFileName = Helper.Helper.UpdateOrderAddress(_UpdateOrderAddressData); if (ReturnFileName != null) { ReturnFileName = ReturnFileName.Trim('"'); TempData["ValidationErrors"] = ReturnFileName; } } List <ListItemModel> ordersList = Helper.Helper.OrdersList(); List <ListItemModel> skuList = Helper.Helper.SKUList(); theModel.ListItemModel = new List <SelectListItem>(); foreach (ListItemModel item in skuList) { theModel.ListItemModel.Add(new SelectListItem { Text = item.Value }); } theModel.OrdersListItemModel = new List <SelectListItem>(); foreach (ListItemModel item in ordersList) { theModel.OrdersListItemModel.Add(new SelectListItem { Text = item.Value }); } return(View("Index", theModel)); }
public static string UpdateOrderAddress(UpdateOrderAddressDto theModel) { string response = string.Empty; var _ReturnDto = new ReturnDto(); string uri = System.Configuration.ConfigurationManager.AppSettings["rooturi"] + System.Configuration.ConfigurationManager.AppSettings["UpdateOrderAddress"]; string token = System.Web.HttpContext.Current.Session["BearerToken"].ToString(); try { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var resp = client.PostAsJsonAsync(uri, theModel); resp.Wait(TimeSpan.FromSeconds(10)); if (resp.IsCompleted) { if (resp.Result.StatusCode == HttpStatusCode.Unauthorized) { Console.WriteLine("Authorization failed. Token expired or invalid."); } else { response = resp.Result.Content.ReadAsStringAsync().Result; _ReturnDto = JsonConvert.DeserializeObject <ReturnDto>(response); response = _ReturnDto.ErrorMessage; if (string.IsNullOrEmpty(response)) { response = _ReturnDto.OrderStatus; } } } } } catch (Exception ex) { response = ex.Message.ToString(); } return(response); }