public static List <Account_Project> GetAccountProjects(Guid organizationId, int departmentId, int accountId) { AccountProjects _AccountProjects = new AccountProjects(bigWebApps.bigWebDesk.Data.Accounts.SelectProjects(organizationId, departmentId, accountId)); return(_AccountProjects.ToList()); }
public static Account_Details GetAccountDetails(ApiUser user, int accountId, bool is_with_statistics) { Models.Account_Details account = null; Instance_Config config = new Instance_Config(user); DataRow accountDetails = bigWebApps.bigWebDesk.Data.Accounts.SelectOne(user.DepartmentId, accountId, user.OrganizationId); if (accountDetails != null) { account = new Account_Details(accountDetails); } else if (accountId == -1 || accountId == 0) { DataTable table = new DataTable(); table.Columns.Add("Name", typeof(string)); table.Columns.Add("Id", typeof(int)); account = new Account_Details(table.NewRow()); account.Name = user.DepartmentName; account.Id = -1; } else { throw new HttpError(HttpStatusCode.NotFound, "Incorrect account id"); } if (config.LocationTracking) { account.Locations = new Locations(bigWebApps.bigWebDesk.Data.Accounts.SelectLocations(user.OrganizationId, user.DepartmentId, accountId)).List; } /* * if (account.ClientContractID.HasValue) * { * DataRow row = bigWebApps.bigWebDesk.Data.Accounts.SelectAccountContract(user.OrganizationId, user.DepartmentId, account.ClientContractID.Value); * account.contract_renewal_date = Functions.DisplayDate((DateTime)row["EndDate"], 0, false); * } */ account.Primary_Contact = Address.GetAccountAddress(user.OrganizationId, user.DepartmentId, accountId); account.Users = AccountUsers.GetAccountUsers(user.OrganizationId, user.DepartmentId, accountId); //Assets if (config.AssetTracking) { account.Assets = Models.Assets.AccountAssets(user, config.Assets, accountId); } if (config.ProjectTracking) { account.Projects = AccountProjects.GetAccountProjects(user.OrganizationId, user.DepartmentId, accountId); } //Custom fields if (accountId > 0) { List <KeyValuePair <string, string> > customFields = new List <KeyValuePair <string, string> >(); for (int i = 1; i < 16; i++) { if ((bool)accountDetails["btCust" + i.ToString() + "On"]) { customFields.Add(new KeyValuePair <string, string>(accountDetails["vchCust" + i.ToString() + "Cap"].ToString(), accountDetails["vchCust" + i.ToString()].ToString())); } } if (!accountDetails.IsNull("btDateCust1On") && (bool)accountDetails["btDateCust1On"]) { customFields.Add(new KeyValuePair <string, string>(accountDetails["vchDateCust1Cap"].ToString(), accountDetails.IsNull("dtCust1") ? "" : Functions.DisplayDate((DateTime)accountDetails["dtCust1"], user.TimeZoneOffset, false))); } if (!accountDetails.IsNull("btDateCust2On") && (bool)accountDetails["btDateCust2On"]) { customFields.Add(new KeyValuePair <string, string>(accountDetails["vchDateCust2Cap"].ToString(), accountDetails.IsNull("dtCust2") ? "" : Functions.DisplayDate((DateTime)accountDetails["dtCust2"], user.TimeZoneOffset, false))); } account.CustomFields = customFields.ToList(); } account.Files = Models.Files.GetFiles(user.InstanceId, accountId, user.OrganizationId, "accounts-accounts-files"); string accountLogoUrl = ""; if (accountId > 0) { accountLogoUrl = Models.Files.GetAccountLogoUrl(user.InstanceId, accountId, user.OrganizationId); } else { accountLogoUrl = string.IsNullOrEmpty(user.InstanceLogoImageUrl) ? user.OrganizationLogoImageUrl : user.InstanceLogoImageUrl; } account.Logo = accountLogoUrl; if (is_with_statistics) { account.account_statistics = AccountStats.GetStatistics(accountId, user.OrganizationId, user.DepartmentId, user.UserId); } return(account); }