예제 #1
0
        public ActionResult Bill(int id, CreateBillInput billInput, int ActivityId)
        {
            var dealer = _dealerAppService.GetDealer(id);


            if (dealer != null)
            {
                var activities = _dealerActivityAppService.GetDealerActivities(dealer);
                var revenue    = _revenueSourceAppService.GetRevenueResource(ActivityId);

                //Dealer Registration Bill

                int bill = _billAppService.CreateBill(billInput);
                if (bill > 0)
                {
                    foreach (var activity in activities)
                    {
                        var item = new CreateBillItemInput
                        {
                            BillId      = bill,
                            ActivityId  = ActivityId,
                            Description = revenue.Description,
                            Loyality    = activity.Activity.Fee + activity.Activity.RegistrationFee,
                            Total       = activity.Activity.Fee + activity.Activity.RegistrationFee
                        };

                        _billItemAppService.CreateBillItem(item);
                        _dealerAppService.UpdateBillControlNumber(dealer, _billAppService.GetBill(bill).ControlNumber);
                    }
                }
                return(RedirectToAction("ApplicationBill", "DealerActivities", new { id = bill }));
            }

            return(RedirectToAction("Create", new { id = dealer.Id }));
        }