public ActionResult CreateOrdersForCrew(int crewGameSuggestionId) { var crewGameSuggestion = facade.GetCrewGameSuggestionGateway().Get(crewGameSuggestionId); List<SuggestionUsersDTO> suggestionUsers = facade.GetSuggestionUsersGateway().GetAll().Where( u => u.CrewGameSuggestionId == crewGameSuggestionId).Where( u=>u.HasConfirmed==true).ToList(); foreach(SuggestionUsersDTO user in suggestionUsers) { //create order var order = new OrderDTO() { Date = DateTime.Now, User = user.User, UserId = user.UserId }; facade.GetOrderGateway().Create(order); var orders = facade.GetOrderGateway().GetAll(); //create orderline var myOrder = orders.Where(o => o.UserId == user.UserId).Last(); var orderline = new OrderlineDTO() { Amount = 1, Discount = cd.CalculateDiscountDKK(suggestionUsers.Count(), crewGameSuggestion.PlatformGame.Price), OrderId = myOrder.Id, PlatformGameId = crewGameSuggestion.PlatformGameId }; facade.GetOrderlineGateway().Create(orderline); } //Delete crew-game-suggestion facade.GetCrewGameSuggestionGateway().Delete(crewGameSuggestion.Id); return RedirectToAction("MyCrew", "Crews", new { id = crewGameSuggestion.CrewId }); }
public OrderGames(OrderDTO order, List<OrderlineDTO> orderlines, List<PlatformGameDTO> platformgames, List<GameDTO> games) { this.order = order; this.orderlines = orderlines; this.platformgames = platformgames; this.games = games; getTotalSum(); }
public IHttpActionResult PostOrder(OrderDTO order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } facade.GetOrderRepository().Add(converter.Reverse(order)); return CreatedAtRoute("DefaultApi", new { id = order.Id }, order); }
public IHttpActionResult PutOrder(int id, OrderDTO order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != order.Id) { return BadRequest(); } facade.GetOrderRepository().Update(converter.Reverse(order)); return StatusCode(HttpStatusCode.NoContent); }
public OrderIndexVM(UserDTO user, List<OrderDTO> orders, OrderDTO selectedOrder) { User = user; Orders = orders; SelectedOrder = selectedOrder; }