public Models.Outputs.ServiceAmountsDTO GetServiceAmounts_old(string username, string password, String DeviceID) { Models.Outputs.ServiceAmountsDTO SDTO = new Models.Outputs.ServiceAmountsDTO(); if (username.Equals(String.Empty) || password.Equals(String.Empty) || password.Equals(String.Empty)) { // LDTO.loginstatus = "false"; } else { var Validate = (from a in db.users where a.name == username && a.password == password && a.RoleID == 6 select a).FirstOrDefault(); if (Validate != null) { //DeviceID = DeviceID.Trim(); //int DevID = (from a in db.Devices where a.IMEI == DeviceID select a.Id).FirstOrDefault(); var Names = (from a in db.Tbl_Account_Users join b in db.Tbl_Accounts on a.AccountId equals b.AccountId join c in db.Agents on b.AgentId equals c.Id where a.AccountUserId == Validate.EntityId && a.UserId == Validate.UserId select new { b.AccountName, c.AgentName, a.AccountId }).FirstOrDefault(); if (Names != null) { SDTO.AccountName = Names.AccountName; SDTO.AgentName = Names.AgentName; List <ServiceAmounts> SAs = new List <ServiceAmounts>(); var AcSer = (from a in db.Tbl_Account_Balance where a.AccountId == Names.AccountId select new { a.ServiceId, a.Balance }).ToList(); if (AcSer.Count() > 0) { var companies = (from b in AcSer join a in db2.Services on b.ServiceId equals a.ID select new { b, a.ServiceName }).ToList(); if (companies.Count() > 0) { foreach (var item in companies) { ServiceAmounts SA = new ServiceAmounts(); SA.ServiceID = Convert.ToInt32(item.b.ServiceId); SA.ServiceName = item.ServiceName; SA.Amount = Convert.ToDouble(item.b.Balance); SAs.Add(SA); } } } SDTO.ServiceAmounts = SAs; } } } return(SDTO); }
public ServiceAmountsDTO GetServiceAmounts(string username, string password, string DeviceID) { ServiceAmountsDTO sdto = new ServiceAmountsDTO(); if ((!username.Equals(string.Empty) && !password.Equals(string.Empty)) && !password.Equals(string.Empty)) { user Validate = (from a in this.db.users where ((a.name == username) && (a.password == password)) && (a.RoleID == 6) select a).FirstOrDefault <user>(); if (Validate == null) { return(sdto); } var Names = (from a in db.Tbl_Account_Users join b in db.Tbl_Accounts on a.AccountId equals b.AccountId join c in db.Agents on b.AgentId equals c.Id where (a.AccountUserId == Validate.EntityId) && (a.UserId == Validate.UserId) select new { AccountName = b.AccountName, AgentName = c.AgentName, AccountId = a.AccountId }).FirstOrDefault(); if (Names == null) { return(sdto); } var Balance = (from a in db.Tbl_Account_Users join b in db.Tbl_Account_WalletBalance on a.AccountId equals b.AccountId where (a.AccountUserId == Validate.EntityId) && (a.UserId == Validate.UserId) select new { AccountWalletBalence = b.Balance, AccountWalletCurrencyCode = b.CurrencyCode }).FirstOrDefault(); sdto.AccountName = Names.AccountName; sdto.AgentName = Names.AgentName; sdto.AccountWalletBalence = Balance != null?Balance.AccountWalletBalence.ToString() : ""; sdto.AccountWalletCurrencyCode = Balance != null ? Balance.AccountWalletCurrencyCode : ""; List <ServiceAmounts> list = new List <ServiceAmounts>(); var source = (from a in db.Tbl_Account_Balance where a.AccountId == Names.AccountId select new { ServiceId = a.ServiceId, Balance = a.Balance }).ToList(); if (source.Count() > 0) { var list3 = (from b in source join a in this.db2.Services on b.ServiceId equals a.ID select new { b = b, ServiceName = a.ServiceName }).ToList(); if (list3.Count() > 0) { foreach (var type in list3) { ServiceAmounts item = new ServiceAmounts { ServiceID = Convert.ToInt32(type.b.ServiceId), ServiceName = type.ServiceName, Amount = Convert.ToDouble(type.b.Balance), translations = getTranslationForText(type.ServiceName) }; list.Add(item); } } } sdto.ServiceAmounts = list; } return(sdto); }