public async Task <JsonResult> getDetails(string idsaleOrder) { var ListDetails = await ISaleOrderDetailsBLL.Get(filter : p => p.SaleOrderID == idsaleOrder); var lisCus = await ICustomerBLL.Get(); var sale = await ISaleOrderBLL.Find(idsaleOrder); LoadSaleDetailsModel temp = new LoadSaleDetailsModel(); List <string> ListTemp = new List <string>(); List <int> tempQuan = new List <int>(); List <LoadSaleDetailsModel> listTemp = new List <LoadSaleDetailsModel>(); foreach (var i in ListDetails) { ListTemp.Add(i.ProductDetailId); } for (int i = 0; i < ListTemp.Count(); i++) { var t = await IProductDetailsBLL.Find(ListTemp[i]); var e = await IProductBLL.Find(t.ProductID); temp.ModelName = e.Model; temp.Color = t.TypeColor.ToString(); temp.PricePro = e.Price; listTemp.Add(temp); } foreach (var i in ListDetails) { tempQuan.Add(i.Quality); } List <string> tempName = new List <string>(); var j = 0; foreach (var i in lisCus) { if (i.Id == sale.CustomerID) { listTemp[j].NameCus = i.CustomerName; listTemp[j].PhoneCus = i.CustomerPhone; listTemp[j].CMND = i.CMND; listTemp[j].AdressDev = sale.ReceiveAddress; j++; } } for (int i = 0; i < listTemp.Count(); i++) { listTemp[i].QuantityPro = tempQuan[i]; listTemp[i].IDsaleOrder = idsaleOrder; } return(Json(JsonConvert.SerializeObject(listTemp))); }
public async Task <JsonResult> GetFullParam([FromBody] getFullParamViewModel ListFullParam) { var i = 0; CM_Customer CurrentCustomer = new CM_Customer() { CustomerName = ListFullParam.Customer.Name, CustomerPhone = ListFullParam.Customer.Phone, CMND = ListFullParam.Customer.CMND, TypeCustomerEnum = Common.Enum.SM.TypeCustomerEnum.KVL }; #region validateSaleOrder SaleOrder CurrentSaleOrder = new SaleOrder() { ReceiveAddress = ListFullParam.saleOrder.ReceiveAddress, TotalPrice = ListFullParam.saleOrder.TotalPrice, PaymentMethod = (Common.Enum.SM.PaymentMethod)ListFullParam.saleOrder.PaymentMethod, DistrictID = ListFullParam.saleOrder.DistrictID, TransportPriceID = ListFullParam.saleOrder.TransportTypeID, }; CurrentSaleOrder.TransportTypePrice = await GetTransportPrice(ListFullParam.saleOrder.TransportPriceID, ListFullParam.saleOrder.TransportTypeID); if (CurrentSaleOrder.TransportTypePrice == -1) { return(Json(new ResponseMessage { Message = "Vui long chon nha van chuyen ", IsSuccess = false })); } #endregion List <SaleOrderDetail> CurrentSaleDetails = new List <SaleOrderDetail>(); foreach (var item in ListFullParam.saleOrderDetails) { var productDetails = await ProductDetailsBLL.Find(item.ProductDetailIDSale); SaleOrderDetail temp = new SaleOrderDetail() { ProductDetailId = item.ProductDetailIDSale, Quality = item.QuantitySale, ProductDetail = productDetails }; CurrentSaleDetails.Add(temp); } var isSuccess = await SaleOrderBLL.CreateBill(CurrentCustomer, CurrentSaleOrder, CurrentSaleDetails); string BaseUrl = string.Format("{0}://{1}", HttpContext.Request.Scheme, HttpContext.Request.Host); if (isSuccess) { if (CurrentSaleOrder.PaymentMethod == Common.Enum.SM.PaymentMethod.Paypal) { string SuccessUrl = BaseUrl + Url.Action("ExcutePayment", "Bill"); string ErrorUrl = BaseUrl + Url.Action("ErrorBill", "Bill"); var payment = await this._paypalServicesGatewayBLL.CreatePayment(SuccessUrl, ErrorUrl, CurrentSaleOrder, CurrentSaleDetails, CurrentCustomer); CurrentSaleOrder.AuthenticationMethodGuid = payment.Id; await this.SaleOrderBLL.Update(CurrentSaleOrder); return(Json(new ResponseMessage { Message = SaleOrderBLL.Message, IsSuccess = isSuccess, errorSaleOrder = SaleOrderBLL.enumErrorSaleOrder, RedirectoURl = payment.Links[1].Href })); } else if (CurrentSaleOrder.PaymentMethod == Common.Enum.SM.PaymentMethod.GDTT) { string SuccessUrl = BaseUrl + Url.Action("PaymentTTTN", "Bill"); string ErrorUrl = BaseUrl + Url.Action("ErrorBill", "Bill"); return(Json(new ResponseMessage { Message = SaleOrderBLL.Message, IsSuccess = isSuccess, errorSaleOrder = SaleOrderBLL.enumErrorSaleOrder, RedirectoURl = SuccessUrl })); } else if (CurrentSaleOrder.PaymentMethod == Common.Enum.SM.PaymentMethod.NganLuong) { var ReturnUrlNganLuong = BaseUrl + Url.Action("PaymentTTTN", "Bill"); string Note = "WEB BMT"; string UrlNLRedirecto = "https://www.nganluong.vn/[email protected]&product_name=" + CurrentSaleOrder.ID + "&price=" + CurrentSaleOrder.TotalPrice + "&return_url=" + ReturnUrlNganLuong + "&comments=" + Note; return(Json(new ResponseMessage { Message = SaleOrderBLL.Message, IsSuccess = isSuccess, errorSaleOrder = SaleOrderBLL.enumErrorSaleOrder, RedirectoURl = UrlNLRedirecto })); } return(Json(new ResponseMessage { Message = SaleOrderBLL.Message, IsSuccess = isSuccess, errorSaleOrder = SaleOrderBLL.enumErrorSaleOrder })); } else { return(Json(new ResponseMessage { Message = SaleOrderBLL.Message, IsSuccess = isSuccess, errorSaleOrder = SaleOrderBLL.enumErrorSaleOrder })); } }