Beispiel #1
0
        public async Task <IActionResult> EditData(string identifier)
        {
            var result = await GetRecipeAction(identifier);

            if (result.Error != null)
            {
                return(result.Error);
            }

            var services = await _externalServiceManager.GetExternalServicesData(new ExternalServicesDataQuery()
            {
                Type   = new[] { ExchangeService.ExchangeServiceType },
                UserId = _userManager.GetUserId(User)
            });

            var vm = new PlaceOrderViewModel()
            {
                ExternalServices = new SelectList(services, nameof(ExternalServiceData.Id),
                                                  nameof(ExternalServiceData.Name), result.Data.ExternalServiceId),
            };

            SetValues(result.Data, vm);

            return(View(vm));
        }
        public IActionResult PlaceOrder(PlaceOrderViewModel placeOrderModel)
        {
            if (ModelState.IsValid)
            {
                //product drop down for selecting product
                var productNameResult = productService.GetAllProducts()
                                        .Select(s => new ProductListModel {
                    Text = s.ProductName, Value = s.ProductId
                }).ToList();;
                var customer = customerService.
                               GetCustomerById(placeOrderModel.SelectedCustomerId);

                OrderViewModel model = new OrderViewModel()
                {
                    ProductNameList = new List <SelectListItem>(),
                    OrderDate       = placeOrderModel.OrderDate,
                    CustomerId      = placeOrderModel.SelectedCustomerId,
                    Customer        = customer
                };

                foreach (var item in productNameResult)
                {
                    model.ProductNameList.
                    Add(new SelectListItem {
                        Text  = item.Text,
                        Value = item.Value.ToString()
                    });
                }

                return(View(model));
            }

            return(NotFound());
        }
        public JsonResult BookOrder(string LotNos, int CustomerId, int ShippingMode, int BillingID, int ShippingID)
        {
            try
            {
                int LoginID = GetLogin();
                if (LoginID > 0)
                {
                    if (CustomerId == 0)
                    {
                        CustomerId = LoginID;
                    }
                    PlaceOrderViewModel rst = objOrderService.BookOrder(LotNos, LoginID, CustomerId, ShippingMode, BillingID, ShippingID);
                    objOrderService.SendMailPreBookOrder(rst.OrderId, LoginID, Server.MapPath(ConfigurationManager.AppSettings["EmailTemplate_PlaceOrderAdmin"]), "Customer order details @ www.rosyblueonline.com");
                    objOrderService.SendMailPreBookOrder(rst.OrderId, LoginID, Server.MapPath(ConfigurationManager.AppSettings["EmailTemplate_PlaceOrderCustomer"]), "Your order details @ www.rosyblueonline.com", true);

                    bool log = this.objUDSvc.UserActivitylogs(LoginID, "Order Book", LotNos);

                    return(Json(new Response {
                        IsSuccess = true, Message = "", Result = rst
                    }));
                }
                return(Json(new Response {
                    IsSuccess = false, Message = string.Format(StringResource.Invalid, "Session")
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLog.Log("OrderController", "BookOrder", ex);
                return(Json(new Response {
                    IsSuccess = false, Message = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult PlaceOrder()
        {
            PlaceOrderViewModel vm = new PlaceOrderViewModel();

            vm.Carts = (List <ProductShoppingCart>)Session["Carts"];
            return(View(vm));
        }
Beispiel #5
0
        public IActionResult PlaceOrder()
        {
            var viewmodel = new PlaceOrderViewModel
            {
                locations       = _lrepo.GetAllLocations(),
                customers       = _crepo.GetAllCustomers(),
                selectedOptions = false,
            };

            // If we come to this page but the cart isn't empty, we need to put the products back into their respective place
            if (HttpContext.Session.GetObject <Dictionary <int, int> >("Cart") != null)
            {
                // Get existing cart, location it was taken from
                var cart       = HttpContext.Session.GetObject <Dictionary <int, int> >("Cart");
                var locationID = HttpContext.Session.GetObject <int>("SelectedLocationID");
                var location   = _lrepo.GetLocation(locationID);
                location.Inventory = _lrepo.GetLocationInventory(locationID);

                // Increase location inventory quantities corresponding with the cart
                foreach (var item in cart)
                {
                    var product = location.Inventory.Where(i => i.Key.ID == item.Key).First().Key;
                    location.Inventory[product] += item.Value;
                }
                // Save changes to the database
                _lrepo.UpdateLocationInventory(location);
                _lrepo.SaveChanges();
            }

            HttpContext.Session.SetObject("Cart", null);

            return(View(viewmodel));
        }
Beispiel #6
0
        public IActionResult PlaceOrder(PlaceOrderViewModel vm)
        {
            Order newOrder = Order.CreateOrder(vm);

            db.Orders.Add(newOrder);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        public async Task <ActionResult> Index(PlaceOrderViewModel viewModel)
        {
            await endpointInstance.Send("Sales", new PlaceOrderCommand
            {
                OrderId = Guid.NewGuid().ToString()
            });

            return(View(viewModel));
        }
Beispiel #8
0
 public PlaceOrderView()
 {
     InitializeComponent();
     using (var scope = Dependencies.container.BeginLifetimeScope())
     {
         SCVM = Dependencies.container.Resolve <PlaceOrderViewModel>();
     }
     BindingContext = SCVM;
 }
        public IActionResult PlaceOrder(PlaceOrderViewModel newOrder)
        {
            // -- If this is a new customer, create the customer record --
            if (string.IsNullOrEmpty(newOrder.Nom))
            {
                ModelState.AddModelError(nameof(newOrder.Nom), "Le nom ne peut être vide.");
                return(View("Index", newOrder));
            }

            var crepo = new CustomerRepository();

            Customer c;

            if (newOrder.CustomerId != Guid.Empty)
            {
                c = crepo.GetCustomerById(newOrder.CustomerId);
            }
            else
            {
                c = crepo.GetCustomerByName(newOrder.Nom);
            }

            if (c == null)
            {
                var newCustomer = new Customer();
                newCustomer.Nom      = newOrder.Nom;
                newCustomer.Prenom   = newOrder.Nom;
                newCustomer.Courriel = newOrder.Nom;
                newCustomer.Adresse  = newOrder.Nom;

                c = crepo.SaveNewCustomer(newCustomer);
            }

            // -- Create the order for the customer. --
            if (string.IsNullOrEmpty(newOrder.Produit))
            {
                ModelState.AddModelError(nameof(newOrder.Produit), "Le produit ne peut être vide.");
                return(View("Index", newOrder));
            }

            if (newOrder.Quantite == 0)
            {
                ModelState.AddModelError(nameof(newOrder.Produit), "La quantité ne peut être inférieure à un.");
                return(View("Index", newOrder));
            }

            var orepo = new OrderRepository();

            Order o = orepo.CreateNewOrder(c);

            o.Prod = newOrder.Produit;
            o.Qty  = newOrder.Quantite;

            orepo.Save(o);

            return(View(nameof(Index)));
        }
Beispiel #10
0
 public IActionResult PlaceOrder(PlaceOrderViewModel model)
 {
     if (!ModelState.IsValid)
     {
         var errorModel = _alCart.GetPlaceOrderModel(model.Order);
         return(View(errorModel));
     }
     _alCart.SaveOrder(model.Order);
     return(RedirectToAction(nameof(OrderConfirmation), "Cart", new { id = model.Order.Id }));
 }
        public async Task <IActionResult> PlaceOrder(
            [FromBody] PlaceOrderViewModel vm)
        {
            var userInfo = GetUserInfo();
            var command  = new PlaceOrder(userInfo, vm.Id, vm.OrderName, vm.Items);

            await _mediator.Send(command);

            return(Ok());
        }
Beispiel #12
0
        private PlaceOrderViewModel InitPOVM(int StoreId)
        {
            TempData["StoreId"] = StoreId;
            var inventoryItemModel = new PlaceOrderViewModel
            {
                Inventory = _storeContext.GetInventory(StoreId)
            };

            ViewData["ProductId"] = new SelectList(_context.GetProducts(), "ProductId", "ProductName", "ProductPrice");
            return(inventoryItemModel);
        }
Beispiel #13
0
        public static Order CreateOrder(PlaceOrderViewModel vm)
        {
            Order newOrder = new Order
            {
                CateringOrderId   = vm.CateringOrderId,
                Quantity          = vm.Quantity,
                CateringProductId = vm.CateringProductId,
            };

            return(newOrder);
        }
        public IActionResult InitOrder(PlaceOrderViewModel placeOrderViewModel)
        {
            var order = new Order()
            {
                Id         = placeOrderViewModel.OrderId,
                CustomerId = int.Parse(placeOrderViewModel.CustomerId),
                StoreId    = int.Parse(placeOrderViewModel.StoreId)
            };

            order = CreateOrder(order);
            return(RedirectToAction("SelectPizza", new { id = order.Id }));
        }
Beispiel #15
0
        public IActionResult PlaceOrder(int id)
        {
            var thisProduct = db.CateringOrders.FirstOrDefault(products => products.CateringOrderId == id);
            //var List = db.CateringProducts.ToList();
            //ViewBag.CateringProductId = new SelectList(db.CateringProducts, "CateringProductId", "Name");

            PlaceOrderViewModel vm = new PlaceOrderViewModel();

            vm.CateringOrderId = thisProduct.CateringOrderId;
            vm.CateringProduct = db.CateringProducts.ToList();
            return(View(vm));
        }
Beispiel #16
0
        public ActionResult Create([Bind(Include = "Item1,Item2")] PlaceOrderViewModel collection)
        {
            try
            {
                // TODO: Add insert logic here

                return(RedirectToAction("Details", new { id = 1 }));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #17
0
        public ActionResult CreateOrder(PlaceOrderViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("PlaceOrder", viewModel));
            }
            OrderStatusViewModel vm        = Mapper.Map <PlaceOrderViewModel, OrderStatusViewModel>(viewModel);
            List <OrderDet>      orderDets = new List <OrderDet>();
            Order ord = new Order();

            ord           = Mapper.Map <PlaceOrderViewModel, Order>(viewModel);
            ord.OrderDets = new List <OrderDet>();
            vm.TotalPrice = "0";

            //Xu ly concurrency
            for (int i = 0; i < viewModel.Carts.Count(); i++)
            {
                Product pr  = Mapper.Map <ProductShoppingCart, Product>(viewModel.Carts[i]);
                Product pr1 = productService.GetById(viewModel.Carts[i].Id);
                if (productService.CheckConcurency(pr))
                {
                    int qty = viewModel.Carts[i].BuyingQuantity;
                    viewModel.Carts[i] = Mapper.Map <Product, ProductShoppingCart>(pr1);
                    viewModel.Carts[i].BuyingQuantity = qty;
                    viewModel.Carts[i].TotalPrice     = (viewModel.Carts[i].BuyingQuantity * double.Parse((viewModel.Carts[i].PromotionalPrice == "1" ? viewModel.Carts[i].Price : viewModel.Carts[i].PromotionalPrice).Replace(".", ""))).ToString();

                    ModelState.AddModelError("ConcurrencyError", "Sản phẩm " + pr1.Name + " đã bị thay đổi thông tin, vui lòng xem lại sản phẩm trước khi mua");
                    return(View("PlaceOrder", viewModel));
                }
                int qty1 = viewModel.Carts[i].BuyingQuantity;
                if (qty1 > pr1.Quantity)
                {
                    ModelState.AddModelError("QuantityError", "Đồng hồ " + pr1.Name + " không còn đủ hàng. Vui lòng chọn số lượng ít hơn.");
                    return(View("PlaceOrder", viewModel));
                }
                pr = productService.GetById(viewModel.Carts[i].Id);

                vm.TotalPrice = (pr.PromotionalPrice == 1?pr.Price * viewModel.Carts[i].BuyingQuantity:pr.PromotionalPrice * viewModel.Carts[i].BuyingQuantity).ToString();
                OrderDet det = new OrderDet();
                det.Quantity     = viewModel.Carts[i].BuyingQuantity;
                det.ProductId    = viewModel.Carts[i].Id;
                det.ProductPrice = pr.PromotionalPrice == 1 ? pr.Price : pr.PromotionalPrice;
                det.Order        = ord;
                ord.OrderDets.Add(det);
                ord.TotalCost += det.ProductPrice * det.Quantity;
            }
            vm.TotalPrice = PriceHelper.NormalizePrice(vm.TotalPrice);
            orderService.AddOrder(ord);
            Session["Carts"] = null;
            return(View("OrderStatus", vm));
        }
Beispiel #18
0
        private void SetValues(RecipeAction from, PlaceOrderViewModel to)
        {
            to.RecipeId          = from.RecipeId;
            to.ExternalServiceId = from.ExternalServiceId;
            var fromData = from.Get <PlaceOrderData>();

            to.Price        = fromData.Price;
            to.Amount       = fromData.Amount;
            to.IsBuy        = fromData.IsBuy;
            to.IsMargin     = fromData.IsMargin;
            to.OrderType    = fromData.OrderType;
            to.StopPrice    = fromData.StopPrice;
            to.MarketSymbol = fromData.MarketSymbol;
        }
 public IActionResult Create()
 {
     try
     {
         var viewModel = new PlaceOrderViewModel()
         {
             Customers = customerService.GetCustomers(),
             Products  = productService.AllProducts(),
             OrderDate = Convert.ToDateTime(DateTime.Today.ToShortDateString())
         };
         return(View(viewModel));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #20
0
        public static Order ViewToOrder(PlaceOrderViewModel order)
        {
            var items = new Dictionary <Product, int>();

            for (int i = 0; i < order.CartItems.Count; i++)
            {
                items.Add(order.CartItems[i], order.CartAmounts[i]);
            }
            var result = new Order
            {
                Customer = order.Customer,
                Location = order.Location,
                Items    = items
            };

            return(result);
        }
        public IActionResult AddProduct(PlaceOrderViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var chosenProduct       = viewModel.chosenProductId;
                    var chosenCustomer      = viewModel.chosenCustomerId;
                    var chosenLocation      = viewModel.chosenLocationId;
                    var chosenProductAmount = viewModel.chosenProductAmount;

                    viewModel = TempData.Get <PlaceOrderViewModel>("Model");

                    var product     = viewModel.Products.Where(x => x.Id == chosenProduct).First();
                    var new_product = new Product
                    {
                        Id    = product.Id,
                        Name  = product.Name,
                        Price = product.Price
                    };

                    viewModel.CartItems.Add(product);
                    viewModel.CartAmounts.Add(chosenProductAmount);
                    viewModel.chosenProductAmount = chosenProductAmount;
                    viewModel.chosenProductId     = chosenProduct;
                    viewModel.chosenLocationId    = chosenLocation;
                    viewModel.chosenCustomerId    = chosenCustomer;

                    TempData.Put("Model", viewModel);

                    logger.LogInformation("Order form valid, adding item and redirecting to create order form");
                    return(RedirectToAction(nameof(Create), viewModel));
                }
                else
                {
                    logger.LogInformation("Order form not valid, redirecting to create order form");
                    return(RedirectToAction(nameof(Create), viewModel));
                }
            }
            catch (Exception e)
            {
                logger.LogInformation(e.Message);
                return(RedirectToAction(nameof(Create), viewModel));
            }
        }
        /// <summary>
        /// returns a view containing drop down fields to place an order, redirects to addproduct
        /// when pressing the add product button and redirects to finalize, when create order is pressed
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public async Task <IActionResult> Create(PlaceOrderViewModel viewModel)
        {
            if (viewModel.New)
            {
                var custData = await repo.GetAllCustomersAsync();

                var customers = custData.Select(x => new Customer
                {
                    Id        = x.Id,
                    FirstName = x.FirstName,
                    LastName  = x.LastName,
                    Email     = x.Email
                }).ToList();

                var locData = await repo.GetAllLocationsAsync();

                var locations = locData.Select(x => new Location
                {
                    Id   = x.Id,
                    Name = x.Name
                }).ToList();

                var prodData = await repo.GetAllProductsAsync();

                var products = prodData.Select(x => new Product
                {
                    Id    = x.Id,
                    Name  = x.Name,
                    Price = x.Price
                }).ToList();

                viewModel.Customers = customers;
                viewModel.Locations = locations;
                viewModel.Products  = products;
                viewModel.New       = false;
            }
            else
            {
                viewModel = TempData.Get <PlaceOrderViewModel>("Model");
            }
            logger.LogInformation("Displaying form to create an order");
            return(View(viewModel));
        }
        public async Task <IActionResult> Finalize(PlaceOrderViewModel viewModel)
        {
            try
            {
                //var chosenProduct = viewModel.chosenProductId;
                var chosenCustomer = viewModel.chosenCustomerId;
                var chosenLocation = viewModel.chosenLocationId;
                //var chosenProductAmount = viewModel.chosenProductAmount;

                viewModel = TempData.Get <PlaceOrderViewModel>("Model");

                //var product = viewModel.Products.Where(x => x.Id == chosenProduct).First();
                //var new_product = new Product
                //{
                //    Id = product.Id,
                //    Name = product.Name,
                //    Price = product.Price
                //};

                //viewModel.CartItems.Add(product);
                //viewModel.CartAmounts.Add(chosenProductAmount);
                //viewModel.chosenProductId = chosenProduct;
                viewModel.chosenLocationId = chosenLocation;
                viewModel.chosenCustomerId = chosenCustomer;

                viewModel.Customer = viewModel.Customers.Where(x => x.Id == chosenCustomer).First();
                viewModel.Location = viewModel.Locations.Where(x => x.Id == chosenLocation).First();

                await repo.AddOrderAsync(OrderHelper.ViewToOrder(viewModel));

                logger.LogInformation($"Order for Customer ID#: {chosenCustomer} at Location ID#: {chosenLocation}" +
                                      $"for {viewModel.CartAmounts.Count} item(s) placed");

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e)
            {
                logger.LogInformation(e.Message);
                return(RedirectToAction(nameof(Index)));
            }
        }
Beispiel #24
0
        public JsonResult PlaceOrder(PlaceOrderViewModel objpPlaceOrderViewModel)
        {
            var OrderNo = Decimal.Parse(String.Format("{0:yyyyMMddHHmmss}", DateTime.Now));

            Order objOrder = new Order();


            objOrder.OrderNo = OrderNo;

            objOrder.CustomerId = objpPlaceOrderViewModel.CustomerId;

            objOrder.PaymentTypeId = objpPlaceOrderViewModel.PaymentTypeId;

            objOrder.Total = objpPlaceOrderViewModel.Total;

            objOrder.Discount = objpPlaceOrderViewModel.Discount;
            db.Orders.Add(objOrder);
            db.SaveChanges();

            foreach (OrderDetail objOrderDetails in objpPlaceOrderViewModel.OrderDetail)
            {
                OrderDetail objOrderDetail = new OrderDetail();
                objOrderDetail.OrderNo  = OrderNo;
                objOrderDetail.ItemId   = objOrderDetails.ItemId;
                objOrderDetail.Quantity = objOrderDetails.Quantity;
                objOrderDetail.Total    = objOrderDetails.Total;
                db.OrderDetails.Add(objOrderDetail);
                db.SaveChanges();

                //OrderTransaction objOrderTransaction = new OrderTransaction();
                //objOrderTransaction.ItemId = objOrderDetails.ItemId;
                //objOrderTransaction.OrderType = true;
                //objOrderTransaction.CustomerId = objpPlaceOrderViewModel.CustomerId;
                //objOrderTransaction.PaymentTypeId = objpPlaceOrderViewModel.PaymentTypeId;
                //objOrderTransaction.Quantity = objOrderDetails.Total;
                //db.OrderTransactions.Add(objOrderTransaction);
                //db.SaveChanges();
            }

            return(Json("", JsonRequestBehavior.AllowGet));
        }
Beispiel #25
0
        public async Task <IActionResult> EditData(string identifier, PlaceOrderViewModel data)
        {
            var result = await GetRecipeAction(identifier);

            if (result.Error != null)
            {
                return(result.Error);
            }


            var externalServiceData = await _externalServiceManager.GetExternalServiceData(data.ExternalServiceId);

            ExchangeService exchangeService = new ExchangeService(externalServiceData);

            if (!ModelState.IsValid)
            {
                var services = await _externalServiceManager.GetExternalServicesData(new ExternalServicesDataQuery()
                {
                    Type   = new[] { ExchangeService.ExchangeServiceType },
                    UserId = _userManager.GetUserId(User)
                });


                data.ExternalServices = new SelectList(services, nameof(ExternalServiceData.Id),
                                                       nameof(ExternalServiceData.Name), data.ExternalServiceId);
                return(View(data));
            }

            var recipeAction = result.Data;

            SetValues(data, recipeAction);

            await _recipeManager.AddOrUpdateRecipeAction(recipeAction);

            return(RedirectToAction("EditRecipe", "Recipes", new
            {
                id = recipeAction.RecipeId,
                statusMessage = "Place Order Action Updated"
            }));
        }
Beispiel #26
0
        public IActionResult PlaceOrder(PlaceOrderViewModel model)
        {
            // locId and custId should hold the id of the selected from before
            int locId  = int.Parse(Request.Form["sel1"]);
            int custId = int.Parse(Request.Form["sel2"]);

            model.selectedLocation = _lrepo.GetLocation(locId);
            model.selectedCustomer = _crepo.GetCustomer(custId);

            model.locations = _lrepo.GetAllLocations();
            model.customers = _crepo.GetAllCustomers();

            model.selectedOptions = true;

            var BLmodel   = _lrepo.GetLocationInventory(locId);
            var viewmodel = BLmodel.Select(i => new LocationInventoryViewModel
            {
                ProductName = i.Key.Name,
                Spice       = i.Key.Spice.Name,
                Price       = i.Key.Price,
                Quantity    = i.Value
            });


            model.Products = viewmodel;

            var addProductModel = new AddProductViewModel
            {
                SelectedCustomer = model.selectedCustomer,
                SelectedLocation = model.selectedLocation
            };

            model.selectedLocation.Inventory = _lrepo.GetLocationInventory(locId);
            TempData["SelectedCustID"]       = model.selectedCustomer.ID;
            TempData["SelectedLocID"]        = model.selectedLocation.ID;


            return(RedirectToAction(nameof(AddProducts)));
        }
        public IActionResult InitOrder()
        {
            List <Customer> customers = GetCustomers();

            ViewBag.Customers = customers.Select(s => new SelectListItem()
            {
                Value = s.Id.ToString(),
                Text  = s.CustomerName
            }).ToList();

            List <Store> stores = GetStores();

            ViewBag.Stores = stores.Select(s => new SelectListItem()
            {
                Value = s.Id.ToString(),
                Text  = s.Name
            }).ToList();

            PlaceOrderViewModel orderViewModel = new PlaceOrderViewModel();

            return(View(orderViewModel));
        }
        public IActionResult Index()
        {
            var customerNameResult = customerService.GetAllCustomers()
                                     .Select(s => new CustomerListModel {
                Text = s.CustomerName, Value = s.CustomerId
            }).ToList();

            PlaceOrderViewModel model = new PlaceOrderViewModel
            {
                CustomerNameList = new List <SelectListItem>()
            };

            foreach (var item in customerNameResult)
            {
                model.CustomerNameList.Add(new SelectListItem {
                    Text = item.Text, Value = item.Value.ToString()
                });
            }

            model.OrderDate = DateTime.Now;

            return(View(model));
        }
Beispiel #29
0
        protected override async Task <(RecipeAction ToSave, PlaceOrderViewModel showViewModel)> BuildModel(
            PlaceOrderViewModel viewModel, RecipeAction mainModel)
        {
            if (viewModel.OrderType == OrderType.Stop && string.IsNullOrEmpty(viewModel.StopPrice))
            {
                ModelState.AddModelError(nameof(PlaceOrderViewModel.StopPrice),
                                         $"Please set a stop price if you wish to place a stop order");
            }

            if (ModelState.IsValid)
            {
                var serviceData =
                    await _externalServiceManager.GetExternalServiceData(viewModel.ExternalServiceId, GetUserId());

                var exchangeService = new ExchangeService(serviceData);
                var symbols         = (await(await exchangeService.ConstructClient()).GetMarketSymbolsAsync()).ToArray();
                if (symbols.Contains(viewModel.MarketSymbol))
                {
                    mainModel.ExternalServiceId = viewModel.ExternalServiceId;
                    mainModel.Set <PlaceOrderData>(viewModel);
                    return(mainModel, null);
                }

                ModelState.AddModelError(nameof(PlaceOrderViewModel.MarketSymbol),
                                         $"The market symbols you entered is invalid. Please choose from the following: {string.Join(",", symbols)}");
            }

            var services = await _externalServiceManager.GetExternalServicesData(new ExternalServicesDataQuery()
            {
                Type   = new[] { ExchangeService.ExchangeServiceType },
                UserId = GetUserId()
            });

            viewModel.ExternalServices = new SelectList(services, nameof(ExternalServiceData.Id),
                                                        nameof(ExternalServiceData.Name), viewModel.ExternalServiceId);
            return(null, viewModel);
        }
Beispiel #30
0
        public async Task <IActionResult> Post([FromBody] PlaceOrderViewModel orderViewModel)
        {
            await _orderAppService.Place(orderViewModel);

            return(Response(orderViewModel));
        }