예제 #1
0
        public TopBranchManagerModel BranchManagerInfo()
        {
            SumGroupByModel branchManagerInfo = context.Database.SqlQuery <SumGroupByModel>("select top 1 sum(TotalAmount) as Column1, BranchManagerId as Id from Invoices group by BranchManagerId order by sum(TotalAmount) desc").First();

            //BranchManager manager = context.BranchManagers.Find(branchManagerInfo.Id);
            TopBranchManagerModel manager = context.Database.SqlQuery <TopBranchManagerModel>("select * from BranchManagers where BranchManagerId = " + branchManagerInfo.Id).First();

            manager.SumAmount = branchManagerInfo.Column1;
            return(manager);
        }
예제 #2
0
        public IHttpActionResult TopBranchDetails()
        {
            SumGroupByModel branchSumAmount = branchRepository.TopSellingBranch();

            Branch branch = branchRepository.Get(branchSumAmount.Id);

            TopBranchViewModel topSellingBranchDetails = new TopBranchViewModel();

            topSellingBranchDetails.Name             = branch.Name;
            topSellingBranchDetails.Address          = branch.Address;
            topSellingBranchDetails.TotalSalesAmount = branchSumAmount.Column1;

            return(Ok(topSellingBranchDetails));
        }
예제 #3
0
        public SumGroupByModel TopSellingBranch()
        {
            SumGroupByModel topBranch = context.Database.SqlQuery <SumGroupByModel>("select branchId as Id, sum(totalAmount) as Column1 from Invoices group by branchId order by sum(TotalAmount) desc").First();

            return(topBranch);
        }