public AccountCollection GetUserAccounts(string usertoken) { Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient(); Business.ApplicationService.accounts[] appaccounts = appclient.Getaccounts(usertoken); AccountCollection AccountCollection = new Models.AccountCollection(); List <AccountgroupCollection> accountgroupcollection = new List <AccountgroupCollection>(); foreach (Business.ApplicationService.accounts item in appaccounts.GroupBy(p => p.categoryid).Select(g => g.First())) { AccountgroupCollection temgroup = new AccountgroupCollection(); temgroup.categoryid = item.categoryid; temgroup.categoryname = item.categoryname; temgroup.userid = item.userid; List <Business.ApplicationService.accounts> resultaccounts = appaccounts.Where(p => p.categoryid == item.categoryid).ToList(); foreach (Business.ApplicationService.accounts subitem in resultaccounts) { PTAccount tempaccount = new PTAccount(); tempaccount.accountId = subitem.accountid; tempaccount.accountName = subitem.accountname; tempaccount.accounttype = subitem.accounttype; tempaccount.amount = (float)Convert.ToDouble(subitem.amount); tempaccount.uniqueid = subitem.unid; tempaccount.categoryid = subitem.categoryid; tempaccount.categoryname = subitem.categoryname; tempaccount.createddate = subitem.createddate; tempaccount.deleted = false; tempaccount.description = subitem.description; tempaccount.duemonth = subitem.duemonth; tempaccount.duedate = subitem.duedate; tempaccount.modifieddate = subitem.modifieddate; tempaccount.providerid = subitem.providerid; tempaccount.providername = subitem.providername; tempaccount.recurrence = subitem.recurrence; tempaccount.subcatid = subitem.subcategoryid; tempaccount.userid = subitem.userid; tempaccount.global = subitem.global; tempaccount.initial = subitem.initial; tempaccount.codes = subitem.codes; temgroup.accounts.Add(tempaccount); } accountgroupcollection.Add(temgroup); } AccountCollection.requestedtime = DateTime.Now.ToString(); AccountCollection.accountcollection = accountgroupcollection; return(AccountCollection); }
public AccountCollection GetUserAccounts(string usertoken) { Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient(); Business.ApplicationService.accounts[] appaccounts = appclient.Getaccounts(usertoken); AccountCollection AccountCollection = new Models.AccountCollection(); List<AccountgroupCollection> accountgroupcollection = new List<AccountgroupCollection>(); foreach (Business.ApplicationService.accounts item in appaccounts.GroupBy(p => p.categoryid).Select(g => g.First())) { AccountgroupCollection temgroup = new AccountgroupCollection(); temgroup.categoryid = item.categoryid; temgroup.categoryname = item.categoryname; temgroup.userid = item.userid; List<Business.ApplicationService.accounts> resultaccounts = appaccounts.Where(p => p.categoryid == item.categoryid).ToList(); foreach (Business.ApplicationService.accounts subitem in resultaccounts) { PTAccount tempaccount = new PTAccount(); tempaccount.accountId = subitem.accountid; tempaccount.accountName = subitem.accountname; tempaccount.accounttype = subitem.accounttype; tempaccount.amount = (float)Convert.ToDouble(subitem.amount); tempaccount.uniqueid = subitem.unid; tempaccount.categoryid = subitem.categoryid; tempaccount.categoryname = subitem.categoryname; tempaccount.createddate = subitem.createddate; tempaccount.deleted = false; tempaccount.description = subitem.description; tempaccount.duemonth = subitem.duemonth; tempaccount.duedate = subitem.duedate; tempaccount.modifieddate = subitem.modifieddate; tempaccount.providerid = subitem.providerid; tempaccount.providername = subitem.providername; tempaccount.recurrence = subitem.recurrence; tempaccount.subcatid = subitem.subcategoryid; tempaccount.userid = subitem.userid; tempaccount.global = subitem.global; tempaccount.initial = subitem.initial; tempaccount.codes = subitem.codes; temgroup.accounts.Add(tempaccount); } accountgroupcollection.Add(temgroup); } AccountCollection.requestedtime = DateTime.Now.ToString(); AccountCollection.accountcollection = accountgroupcollection; return AccountCollection; }