public ActionResult HomeDel(HomeDelivery home) { try { HomeDelivery ff = new HomeDelivery(); ff.Address = home.Address; ff.CustomerId = Convert.ToInt32(Session["UserId"]); ff.Contact = home.Contact; dd.HomeDeliveries.Add(ff); dd.SaveChanges(); TempData["Message"] = "Dear Customer, Ride will be at your place shortly"; return(View()); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } return(View()); }
public ViewResult Home(HomeDelivery homeDelivery) { if (ModelState.IsValid) { HomeRepository.AddFeedback(homeDelivery); return(View("HomeThanks", homeDelivery)); } else { return(View()); } }
public async Task <HttpResponseMessage> HomeDelivery(int orderId, HomeDelivery value) { if (Merchant.IsEnable == false && Merchant.Type != "B") { return(Request.CreateResponse(new { message = "請啟用物流或更改為 B2C 類型" })); } value.MerchantID = Merchant.MerchantID; value.HashKey = Merchant.HashKey; value.HashIV = Merchant.HashIV; value.SenderName = Merchant.SenderName; value.SenderPhone = Merchant.SenderPhone; value.SenderCellPhone = Merchant.SenderCellphone; value.MerchantTradeDate = DateTime.Now.ToString(); value.IsCollection = Merchant.IsCollection ? "Y" : "N"; value.SenderZipCode = Merchant.SenderZipcode; value.SenderAddress = Merchant.SenderAddress; value.ServerReplyURL = $"{Http}://{Host}/api/ECPay/ECPay/Message?orderId={orderId}";//Server 端回覆網址 _homeDelivery.EnableSecurityProtocol = true; var request = await _homeDelivery.PostAsyncForECPay(Links.Create, value); if (request.Success) { if (request.Response.Substring(0, 1) != "0" && request.Response.Substring(0, 2) != "10") { var json = ObjectConvert <StatusNotification> .QueryStringToJson(request.Response); if (json.RtnCode == 300) { string info = await TradeInfo(json); if (int.TryParse(info, out int temp)) { _orderRepository.UpdateOrder(orderId, json.AllPayLogisticsID, "080", temp); } var ptd = new PrintTradeDocument { MerchantID = Merchant.MerchantID, AllPayLogisticsID = json.AllPayLogisticsID, PlatformID = "", HashKey = Merchant.HashKey, HashIV = Merchant.HashIV }; string printHtml = _tradeDocument.PrintForECPay(Links.TradeDocument, ptd); return(Request.CreateResponse(new { html = printHtml })); } else { return(Request.CreateResponse(new { message = json.RtnMsg })); } } else { return(Request.CreateResponse(new { message = request.Response })); } } else { return(Request.CreateResponse(new { message = request.Message })); } }