public async void SetSMSCredits() { try { SMSHelper helper = new SMSHelper(); SMSCredits = await helper.CheckCredits(); } catch (Exception e) { ExceptionLogging.LogException(e); } }
public async void Initialize() { using (FreeMarketEntities db = new FreeMarketEntities()) { DateTime minDate; if (db.OrderHeaders.FirstOrDefault() == null) { minDate = DateTime.Now.AddYears(-1); } else { minDate = (DateTime)db.OrderHeaders.Min(c => c.OrderDatePlaced); } DateTime maxDate = DateTime.Now; int i = minDate.Year; YearOptions = new List <SelectListItem>(); YearOptions.Add(new SelectListItem { Text = "Since Inception", Value = "0" }); while (i <= maxDate.Year) { YearOptions.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString(), Selected = (i.ToString() == SelectedYear ? true : false) }); i++; } RatingsInformation = new RatingsInfo(); Customers = new List <AspNetUser>(); Customers = db.AspNetUsers.ToList(); AllOrders = db.OrderHeaders.OrderByDescending(c => c.OrderNumber).ToList(); Invoices = db.OrderHeaders.Where(c => c.OrderStatus == "Invoiced").OrderByDescending(c => c.OrderNumber).ToList(); ConfirmedOrders = db.OrderHeaders.Where(c => c.OrderStatus == "Confirmed").OrderByDescending(c => c.OrderNumber).ToList(); InTransitOrders = db.OrderHeaders.Where(c => c.OrderStatus == "InTransit").OrderByDescending(c => c.OrderNumber).ToList(); RefundPending = db.OrderHeaders.Where(c => c.OrderStatus == "RefundPending").OrderByDescending(c => c.OrderNumber).ToList(); RefundableOrders = db.OrderHeaders.Where(c => c.OrderStatus == "Confirmed" || c.OrderStatus == "InTransit").ToList(); TotalSales = SalesInformation.SalesDetails.Sum(c => c.Value); List <AuditUser> hits = new List <AuditUser>(); hits = db.AuditUsers.Where(c => c.Action == 32).ToList(); if (hits.Count > 0) { WebsiteHits = hits.Count; } try { SMSHelper helper = new SMSHelper(); SMSCredits = await helper.CheckCredits(); } catch (Exception e) { ExceptionLogging.LogException(e); } } }