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); }
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)); }
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); }