コード例 #1
0
ファイル: EventService.cs プロジェクト: FelixLeChat/IOU-Slack
        public List <string> Fix(SplitFixModel splitFixModel)
        {
            var eventSubeventSubscriptionService = new EventSubscriptionService();

            var eventSubscriptions = eventSubeventSubscriptionService.GetAll(splitFixModel.EventID);

            // Get Current Event
            var ev = Get(splitFixModel.EventID);

            ev.Price = splitFixModel.Amount;

            // update Event
            Update(ev);

            // Generate Debts
            var userList    = new List <string>();
            var debtService = new DebtService();

            foreach (var eventSubscription in eventSubscriptions)
            {
                userList.Add(eventSubscription.UserName);
                // Debt Creation
                debtService.Create(new Debt()
                {
                    AmountDue = ev.Price,
                    EventID   = splitFixModel.EventID,
                    UserID    = eventSubscription.UserID
                });
            }

            return(userList);
        }
コード例 #2
0
ファイル: EventService.cs プロジェクト: FelixLeChat/IOU-Slack
        public List <string> Split(SplitFixModel splitFixModel)
        {
            var eventSubeventSubscriptionService = new EventSubscriptionService();

            // Get User List
            var users            = eventSubeventSubscriptionService.GetAll(splitFixModel.EventID);
            var participantCount = users.Count;

            if (participantCount == 0)
            {
                throw HttpResponseExceptionHelper.Create("No one has subscribed to the event", HttpStatusCode.BadRequest);
            }

            splitFixModel.Amount = splitFixModel.Amount / participantCount;

            return(Fix(splitFixModel));
        }