public ViewModels.OrderViewModel ProcessOrder(ViewModels.OrderViewModel orderViewModel, bool SentFromStoreUser) { switch (orderViewModel.OrderState) { case Enums.EnumOrderState.Undef: //its a new order orderViewModel = orderRepository.AddOrder(orderViewModel.Items, orderViewModel.CustomerUser, orderViewModel.StoreUser); GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Clients( Utils.SignalRServiceUtils.JoinClientLists(orderViewModel.CustomerUser.SignalRConnections, orderViewModel.StoreUser.SignalRConnections) ).updateOrder(orderViewModel); break; case Enums.EnumOrderState.ClientPlacedOrder: //the item has been acknowledged from Server orderViewModel.OrderState = Enums.EnumOrderState.HostConfirmedOrder; orderRepository.UpdateOrderState(orderViewModel.OrderIdentifier, Enums.EnumOrderState.HostConfirmedOrder); GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Clients( Utils.SignalRServiceUtils.JoinClientLists(orderViewModel.CustomerUser.SignalRConnections, orderViewModel.StoreUser.SignalRConnections) ).updateOrder(orderViewModel); break; case Enums.EnumOrderState.HostConfirmedOrder: //the item has been receive-ack by client orderViewModel.OrderState = Enums.EnumOrderState.ClientOrderFinished; orderRepository.UpdateOrderState(orderViewModel.OrderIdentifier, Enums.EnumOrderState.ClientOrderFinished); GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Clients( Utils.SignalRServiceUtils.JoinClientLists(orderViewModel.CustomerUser.SignalRConnections, orderViewModel.StoreUser.SignalRConnections) ).updateOrder(orderViewModel); break; case Enums.EnumOrderState.ClientOrderFinished: break; case Enums.EnumOrderState.ServerOrderFinished: break; case Enums.EnumOrderState.Cancel: break; case Enums.EnumOrderState.Error: break; default: break; } return(orderViewModel); }
public ActionResult StripePay(string tokenid, string orderid) { var order = orderRepository.GetOrder(orderid); var amount = Utils.OrderUtils.GetToals(orderid); var service = db.ServiceSettings.FirstOrDefault(ln => ln.Owner.ID == order.StoreUser.Id); var stripesettings = service.StripeSettings.FirstOrDefault(); var orderProcessFactory = Factories.OrderProcessFactory.GetOrderProcessImplementation(service.ServiceType); if (StripeCharge(order.CustomerUser.Name, tokenid, amount, "eur", order.OrderIdentifier, stripesettings.SecretKey)) { order.PaymentState = Enums.EnumPaymentState.IsPaid; order.OrderState = Enums.EnumOrderState.ServerOrderFinished; } else { order.PaymentState = Enums.EnumPaymentState.FailedPaiment; } orderRepository.UpdateOrderState(order.OrderIdentifier, order.OrderState); orderRepository.UpdatePaymentState(order.OrderIdentifier, order.PaymentState); orderProcessFactory.ProcessOrder(order, true); //get process implementation - set paystate ... return(Json("tadaaa...", JsonRequestBehavior.AllowGet)); }
public ViewModels.OrderViewModel ProcessOrder(ViewModels.OrderViewModel orderViewModel, bool SentFromStoreUser) { switch (orderViewModel.OrderState) { case Enums.EnumOrderState.Undef: //its a new order orderViewModel = orderRepository.AddOrder(orderViewModel.Items, orderViewModel.CustomerUser, orderViewModel.StoreUser); GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Clients( Utils.SignalRServiceUtils.JoinClientLists(orderViewModel.CustomerUser.SignalRConnections, orderViewModel.StoreUser.SignalRConnections) ).updateOrder(orderViewModel); break; case Enums.EnumOrderState.ClientPlacedOrder: //the item has been acknowledged from Server if (SentFromStoreUser) { orderViewModel.OrderState = Enums.EnumOrderState.HostConfirmedOrder; orderRepository.UpdateOrderState(orderViewModel.OrderIdentifier, Enums.EnumOrderState.HostConfirmedOrder); //set payment to due orderViewModel.PaymentState = Enums.EnumPaymentState.IsDue; orderRepository.UpdatePaymentState(orderViewModel.OrderIdentifier, Enums.EnumPaymentState.IsDue); GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Clients( Utils.SignalRServiceUtils.JoinClientLists(orderViewModel.CustomerUser.SignalRConnections, orderViewModel.StoreUser.SignalRConnections) ).updateOrder(orderViewModel); } else { orderViewModel.ErrorMessage = "Wrong state .... should not happen..."; } break; case Enums.EnumOrderState.HostConfirmedOrder: if (SentFromStoreUser) { //store user launched shipping orderViewModel.ShippingState = Enums.EnumShippingState.Launched; orderRepository.UpdateShippingState(orderViewModel.OrderIdentifier, Enums.EnumShippingState.Launched); } else { //the item has been receive-ack by client orderViewModel.ShippingState = Enums.EnumShippingState.Delivered; orderRepository.UpdateShippingState(orderViewModel.OrderIdentifier, Enums.EnumShippingState.Delivered); orderViewModel.OrderState = Enums.EnumOrderState.ClientOrderFinished; orderRepository.UpdateOrderState(orderViewModel.OrderIdentifier, Enums.EnumOrderState.ClientOrderFinished); } GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Clients( Utils.SignalRServiceUtils.JoinClientLists(orderViewModel.CustomerUser.SignalRConnections, orderViewModel.StoreUser.SignalRConnections) ).updateOrder(orderViewModel); break; case Enums.EnumOrderState.ClientOrderFinished: break; case Enums.EnumOrderState.ServerOrderFinished: //payment has been processed in paymentcontroller, //send update to clients and hosts GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Clients( Utils.SignalRServiceUtils.JoinClientLists(orderViewModel.CustomerUser.SignalRConnections, orderViewModel.StoreUser.SignalRConnections) ).updateOrder(orderViewModel); break; case Enums.EnumOrderState.Cancel: break; case Enums.EnumOrderState.Error: break; default: break; } return(orderViewModel); }