コード例 #1
0
ファイル: HttpHandlers.cs プロジェクト: ab316/AdfenixTest
        private static void SetGetFranchiseHttpGetHandler()
        {
            Handle.GET(Utils.MakeUrl("partial/franchise/{?}"), (string id) =>
            {
                var franchiseJson  = new FranchisesJson();
                var franchise      = (Franchise)DbHelper.FromID(DbHelper.Base64DecodeObjectID(id));
                franchiseJson.Data = DbHelper.FromID(DbHelper.Base64DecodeObjectID(id));
                franchiseJson.url  = Utils.MakeUrl("franchise/" + id);

                FranchiseUtils.PopulateFranchiseMetrics(franchise, franchiseJson);

                return(franchiseJson);
            });
        }
コード例 #2
0
ファイル: FranchiseUtils.cs プロジェクト: ab316/AdfenixTest
        public static void PopulateFranchiseMetrics(Franchise franchise, FranchisesJson franchiseJson)
        {
            UInt32  homesSold       = 0;
            decimal totalSale       = 0;
            decimal totalCommission = 0;

            foreach (Transaction t in franchise.transactions)
            {
                homesSold++;
                totalSale       += t.salesPrice;
                totalCommission += t.commission;
            }

            franchiseJson.homesSold       = homesSold;
            franchiseJson.totalCommission = totalCommission;
            franchiseJson.positiveTrend   = CalculatePositiveTrend(franchise);
            if (homesSold > 0)
            {
                franchiseJson.averageCommission = totalCommission / homesSold;
            }
        }