public IHttpActionResult GetAccounts(DateTime reqDate, string serialNo) { serialNo = serialNo.Trim().ToLower(); var terminal = TerminalServices.GetTerminalBySerial(serialNo); if (terminal == null) { return(Unauthorized()); } var result = new AccountSyncCollection(); var allAccounts = _accountServices.GetAllValidAccounts(terminal.TenantId, EnumAccountType.All, null, reqDate, true); var accounts = new List <AccountSync>(); foreach (var p in allAccounts) { var account = new AccountSync(); var mappedAccount = AutoMapper.Mapper.Map(p, account); mappedAccount.CountryName = p.GlobalCountry.CountryName; mappedAccount.CurrencyName = p.GlobalCurrency.CurrencyName; mappedAccount.PriceGroupName = p.TenantPriceGroups.Name; mappedAccount.PriceGroupID = p.PriceGroupID; mappedAccount.FullAddress = p.FullAddress; accounts.Add(mappedAccount); } result.Count = accounts.Count; result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, accounts.Count(), terminal.TerminalId, TerminalLogTypeEnum.AccountsSync).TerminalLogId; result.Accounts = accounts; return(Ok(result)); }
// GET: TenantConfigs/Create public ActionResult Create() { var tenantConfig = _tenantsServices.GetTenantConfigById(CurrentTenantId); if (tenantConfig != null) { ViewBag.DefaultCashAccountID = new SelectList(_accountServices.GetAllValidAccounts(CurrentTenantId).ToList(), "AccountID", "AccountCode", tenantConfig.DefaultCashAccountID); return(View(tenantConfig)); } ViewBag.DefaultCashAccountID = new SelectList(_accountServices.GetAllValidAccounts(CurrentTenantId).ToList(), "AccountID", "AccountCode"); return(View()); }
protected void SetViewBagItems(Order order = null, EnumAccountType accountType = EnumAccountType.All) { ViewBag.Accounts = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, accountType), "AccountID", "AccountNameCode"); var Tenant = caCurrent.CurrentTenant(); if (Tenant != null) { var tenantMainLocation = new PropertyContactInfo() { PropertyCode = "TenantLocMain", AddressLine1 = Tenant.TenantAddress1, AddressLine2 = Tenant.TenantAddress2, AddressLine3 = Tenant.TenantAddress3, AddressLine4 = Tenant.TenantAddress4, AddressPostcode = Tenant.TenantPostalCode }; var addressList = new List <PropertyContactInfo>() { tenantMainLocation }; foreach (var location in Tenant.TenantLocations.OrderBy(m => m.WarehouseName)) { addressList.Add(new PropertyContactInfo() { AddressLine1 = location.AddressLine1, AddressLine2 = location.AddressLine2, AddressLine3 = location.AddressLine3, AddressLine4 = location.AddressLine4, AddressPostcode = location.PostalCode, PropertyCode = "TenantLoc" + location.WarehouseId }); } ViewBag.TenantAddresses = addressList.Select(m => new SelectListItem() { Text = m.FullAddress(), Value = m.PropertyCode, Selected = m.PropertyCode == "TenantLoc" + order?.ShipmentWarehouseId ? true : false }); var reportTypes = LookupServices.GetAllReportTypes(CurrentTenantId).ToList(); var rTypes = reportTypes.Where(x => x.AllowReportType == true).Select(repTypes => new { repTypes.ReportTypeId, repTypes.TypeName }).ToList(); var cTypes = reportTypes.Where(x => x.AllowChargeTo == true).Select(repTypes => new { repTypes.ReportTypeId, repTypes.TypeName }).ToList(); ViewBag.ReportTypes = new SelectList(rTypes, "ReportTypeId", "TypeName", (order != null ? order.ReportTypeId : null)); ViewBag.ReportTypeChargeTo = new SelectList(cTypes, "ReportTypeId", "TypeName", (order != null ? order.ReportTypeChargeId : null)); } var properties = PropertyService.GetAllValidProperties(); ViewBag.PropertyAddresses = new SelectList(properties, "PPropertyId", "FullAddress"); ViewBag.Properties = new SelectList(properties, "PPropertyId", "FullAddress"); ViewBag.Properties = new SelectList(properties, "PPropertyId", "FullAddress", order?.AccountAddressId); var loans = LookupServices.GetAllValidTenantLoanTypes(CurrentTenantId).Select(ln => new { LoanID = ln.LoanID, LoanName = ln.LoanName + " - Loan Days= " + ln.LoanDays }).ToList(); ViewBag.TenantLoanTypes = new SelectList(loans, "LoanID", "LoanName"); ViewBag.AuthUsers = new SelectList(OrderService.GetAllAuthorisedUsers(CurrentTenantId), "UserId", "UserName", order != null ? order.CreatedBy : CurrentUserId); ViewBag.JobTypes = new SelectList(OrderService.GetAllValidJobTypes(CurrentTenantId), "JobTypeId", "Name", order != null && order.JobTypeId > 0 ? order.JobTypeId : null); ViewBag.JobSubTypes = new SelectList(OrderService.GetAllValidJobSubTypes(CurrentTenantId), "JobSubTypeId", "Name", order != null && order.JobSubTypeId > 0 ? order.JobSubTypeId : null); ViewBag.Departments = new SelectList(LookupServices.GetAllValidTenantDepartments(CurrentTenantId), "DepartmentId", "DepartmentName"); ViewBag.SLAPs = new SelectList(LookupServices.GetAllValidSlaPriorities(CurrentTenantId), "SLAPriorityId", "Priority"); ViewBag.AccountContacts = new SelectList(AccountServices.GetAllTopAccountContactsByTenantId(CurrentTenantId), "AccountContactId", "ContactName", order?.AccountContactId); ViewBag.AccountContacts = new SelectList(AccountServices.GetAllValidAccountContactsByAccountId(order?.AccountID ?? 0, CurrentTenantId), "AccountContactId", "ContactName", order?.AccountContactId); ViewBag.AccountAddress = new SelectList(AccountServices.GetAccountAddress(), "AddressID", "FullAddressText", order?.AccountAddressId); ViewBag.CurrentUserName = CurrentUser.UserName; if (order != null) { ViewBag.OrderNotesList = order.OrderNotes.Where(x => x.IsDeleted != true).Select(s => new OrderNotesViewModel() { Notes = s.Notes, OrderNoteId = s.OrderNoteId, NotesByName = OrderService.GetAuthorisedUserNameById(s.CreatedBy ?? 0), NotesDate = s.DateCreated }).ToList(); ViewBag.OrderDetails = order.OrderDetails; ViewBag.OrderProcesses = order.OrderProcess; ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "AccountID", "CompanyName", order.AccountID); } var expecMints = new Dictionary <string, string>(); for (var h = 0; h <= 7; h++) { for (var m = 0; m <= 45; m += 15) { if (h == 0 && m == 0) { continue; } if (h == 7 && m == 45) { continue; } expecMints.Add(((h * 60) + m).ToString(), h + " hour " + (m > 0 ? m + " minutes" : "")); } } for (var i = 2; i <= 5; i++) { expecMints.Add((TimeSpan.FromDays(i).TotalMinutes).ToString(), i + " days"); } if (order != null && order.OrderID > 0) { ViewBag.ExpectedHoursList = order.ExpectedHours != null ? new SelectList(expecMints, "Key", "Value", order.ExpectedHours.Value) : new SelectList(expecMints, "Key", "Value"); var tenants = PropertyService.GetAppointmentRecipientTenants(order.OrderID).ToList(); if (tenants.Any(i => i != null)) { List <int> selectedTIds = tenants.Select(m => m.PTenantId).ToList(); ViewBag.PropertyTenants = new MultiSelectList(PropertyService.GetAllCurrentTenants(order.PPropertyId ?? 0), "PTenantId", "TenantFullName", selectedTIds); ViewBag.PropertyTenantIds = selectedTIds; } else { ViewBag.PropertyTenants = new MultiSelectList(PropertyService.GetAllCurrentTenants(order.PPropertyId ?? 0), "PTenantId", "TenantFullName"); } } else { ViewBag.ExpectedHoursList = new SelectList(expecMints, "Key", "Value"); } }