コード例 #1
0
        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 });
        }
コード例 #2
0
 public IHttpActionResult PostOrderline(OrderlineDTO orderline)
 {
     if (!ModelState.IsValid)
     {
         return BadRequest(ModelState);
     }
     facade.GetOrderlineRepository().Add(new OrderlineConverter().Reverse(orderline));
     return CreatedAtRoute("DefaultApi", new { id = orderline.Id }, orderline);
 }
コード例 #3
0
        public IHttpActionResult PutOrderline(int id, OrderlineDTO orderline)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != orderline.Id)
            {
                return BadRequest();
            }
            facade.GetOrderlineRepository().Update(new OrderlineConverter().Reverse(orderline));

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #4
0
 // GET: Admin/Order/NewGameToOrder/5
 public ActionResult NewGameToOrder(int orderId)
 {
     ViewBag.GameList = new SelectList(facade.GetPlatformGameGateway().GetAll().OrderBy(g => g.Game.Title), "Id", "GamePlatformName");
     var orderline = new OrderlineDTO() { OrderId = orderId };
     return View(orderline);
 }