public ActionResult SelectT([Bind("CustomerID,BearNumber")] OrderViewModel viewModel) { ViewBag.CustomerID = viewModel.CustomerID; ViewBag.CustomerName = RepoC.GetCustomerById(viewModel.CustomerID).FirstName + " " + RepoC.GetCustomerById(viewModel.CustomerID).LastName; ViewBag.BearNumber = viewModel.BearNumber; IEnumerable <Training> products = RepoP.GetProducts(); IEnumerable <ProductViewModel> viewModels = products.Select(x => new ProductViewModel { Id = x.ID, Name = x.Name, Price = x.Price }).Where(x => x.Name != "Bear"); return(View(viewModels)); }
public ActionResult Finish(List <int> TrainingArray, int CustomerID, int LocationID) { IEnumerable <Training> products = RepoP.GetProducts(); Order viewModel = new Order(); viewModel.bears = new List <OrderBear>(); int tester = 0; for (int i2 = 0; i2 < TrainingArray.Where(x => x == 0).Count(); i2++) { OrderBear sbvm = new OrderBear(); sbvm.upgrades = new List <TrainingContainer>(); while (TrainingArray[tester] != 0) { var p = Mapper.Map(products.First(x => x.ID == TrainingArray[tester])); TrainingContainer st = new TrainingContainer() { Product = Mapper.Map(p) }; ; sbvm.AddTraining(st); tester++; } viewModel.AddBear(sbvm); tester++; } Customer c = RepoC.GetCustomerById(CustomerID); viewModel.CustomerID = c.Id; Location selectedlocation = RepoL.GetLocationById(LocationID); Order finishedorder = viewModel; selectedlocation.ProcessOrder(finishedorder); finishedorder.Location = selectedlocation; RepoL.UpdateLocation(selectedlocation); RepoO.AddOrder(finishedorder); RepoL.Save(); RepoO.Save(); return(View()); }