Ejemplo n.º 1
0
        public ActionResult EditBalanceView(long balanceId, long userId)
        {
            if (!CurrentUser.IsAdmin)
            {
                throw new Exception("Unauthorized user access");
            }
            var balance = new BalanceToAwardService().RetrieveBalanceToAwardById(balanceId);

            if (balance == null)
            {
                throw new Exception("Record was not found");
            }
            List <SelectListItem> cycles = new CycleService().RetrieveCyclesList()
                                           .Select(cycle => new SelectListItem
            {
                Text  = cycle.StartDate.ToString("MM/dd/yyyy") + " - " + cycle.EndDate.ToString("MM/dd/yyyy"),
                Value = cycle.CycleId.ToString()
            }).ToList();

            var viewModel = new BalanceToAwardViewModel
            {
                BalanceToAwardId = balance.BalanceToAwardId,
                Balance          = balance.Balance,
                EffectiveDate    = balance.EffectiveDate,
                Cycles           = cycles,
                CycleId          = balance.Cycle.CycleId,
                UserId           = userId
            };

            return(PartialView("~/Views/Admin/_EditBalance.cshtml", viewModel));
        }
Ejemplo n.º 2
0
        public void CurrentCycleTest()
        {
            int cycle = CycleService.CurrentCycle();

            Assert.IsTrue(cycle > 200);
            Assert.IsTrue(cycle < 500);
        }
Ejemplo n.º 3
0
        public void TimeTillTickTest()
        {
            TimeSpan time = CycleService.TimeTillTick();

            Assert.IsTrue(time != TimeSpan.MaxValue);
            Assert.IsTrue(time > TimeSpan.Zero);
            Assert.IsTrue(time.Days < 7);
        }
Ejemplo n.º 4
0
        public void CycleImminentTest()
        {
            int  day      = (int)(DateTime.UtcNow.DayOfWeek);
            int  hour     = DateTime.UtcNow.Hour;
            bool imminent = (day == 3 && hour >= 19) || (day == 4 && hour < 7);

            Assert.AreEqual(imminent, CycleService.CycleImminent());
        }
 public DICycleController(
     CycleService cycleService,
     ICycleTransient transientCycle,
     ICycleScoped scopedCycle,
     ICycleSingleton singletonCycle,
     ICycleSingletonInstance singletonInstanceCycle)
 {
     CycleService           = cycleService;
     TransientCycle         = transientCycle;
     ScopedCycle            = scopedCycle;
     SingletonCycle         = singletonCycle;
     SingletonInstanceCycle = singletonInstanceCycle;
 }
Ejemplo n.º 6
0
        public void FinalDayTest()
        {
            DateTime currentUTC = DateTime.UtcNow;
            int      day        = (int)currentUTC.DayOfWeek;
            int      hour       = currentUTC.Hour;

            if ((day == 3 && hour >= 7) || (day == 4 && hour < 7))
            {
                Assert.IsTrue(CycleService.FinalDay());
            }
            else
            {
                Assert.IsFalse(CycleService.FinalDay());
            }
        }
Ejemplo n.º 7
0
        public void TimeRemainingTest()
        {
            string   timeRemaining = CycleService.TimeRemaining();
            TimeSpan time          = CycleService.TimeTillTick();

            Assert.IsTrue(timeRemaining.IndexOf("hour") > 0);
            if (time.Days == 0)
            {
                Assert.IsTrue(timeRemaining.IndexOf("minute") > 0);
            }
            else
            {
                Assert.IsTrue(timeRemaining.IndexOf("day") > 0);
            }
        }
Ejemplo n.º 8
0
        public ActionResult EditCycleView(long?cycleId)
        {
            var cycle = new CycleService().RetrieveCycleById(cycleId.Value);

            if (cycle == null)
            {
                throw new Exception("Cycle was not found");
            }
            var viewModel = new CycleViewModel
            {
                CycleId   = cycle.CycleId,
                StartDate = cycle.StartDate,
                EndDate   = cycle.EndDate
            };

            return(PartialView("~/Views/Admin/_EditCycle.cshtml", viewModel));
        }
Ejemplo n.º 9
0
        public ActionResult Cycles()
        {
            if (!CurrentUser.IsAdmin)
            {
                throw new Exception("Unauthorized user access");
            }
            List <CycleViewModel> cycles = new CycleService().RetrieveCyclesList()
                                           .Select(
                cyc => new CycleViewModel
            {
                CycleId   = cyc.CycleId,
                StartDate = cyc.StartDate,
                EndDate   = cyc.EndDate
            }
                ).ToList();

            return(View("Cycles", cycles));
        }
Ejemplo n.º 10
0
        public ActionResult AddBulkBalanceView()
        {
            if (!CurrentUser.IsAdmin)
            {
                throw new Exception("Unauthorized user access");
            }
            List <SelectListItem> cycles = new CycleService().RetrieveCyclesList()
                                           .Select(cycle => new SelectListItem
            {
                Text  = cycle.StartDate.ToString("MM/dd/yyyy") + " - " + cycle.EndDate.ToString("MM/dd/yyyy"),
                Value = cycle.CycleId.ToString()
            }).ToList();
            BalanceToAwardViewModel viewModel = new BalanceToAwardViewModel
            {
                Cycles  = cycles,
                BulkAdd = true
            };

            return(PartialView("~/Views/Admin/_AddBalance.cshtml", viewModel));
        }
Ejemplo n.º 11
0
        public ActionResult AddUserView()
        {
            List <SelectListItem> userDropDownItems = new AdminService().GetAllValidToAddUsers()
                                                      .Select(name => new SelectListItem
            {
                Text  = name.Item1,
                Value = name.Item2
            }).ToList();
            List <SelectListItem> cycles = new CycleService().RetrieveCyclesList()
                                           .Select(cycle => new SelectListItem
            {
                Text  = cycle.StartDate.ToString("MM/dd/yyyy") + " - " + cycle.EndDate.ToString("MM/dd/yyyy"),
                Value = cycle.CycleId.ToString()
            }).ToList();
            UserViewModel viewModel = new UserViewModel
            {
                Users  = userDropDownItems,
                Cycles = cycles
            };

            return(PartialView("~/Views/Admin/_AddUser.cshtml", viewModel));
        }
Ejemplo n.º 12
0
        private void UpdateTimeRemaining()
        {
            TimeRemaining = CycleService.TimeRemaining();
            CycleImminent = CycleService.CycleImminent();
            if (CycleImminent)
            {
                TimeRemainingColor = Color.DarkRed;
            }
            else
            {
                TimeRemainingColor = ThemeHelper.GetThemeColor("brandColor");
            }
            ShowTimeRemaining = !settings.OnlyShowNextCycleWhenImminent || CycleService.CycleImminent();

            if (pageVisible && (CycleService.FinalDay() || DateTime.UtcNow.Minute == 59))
            {
                Device.StartTimer(TimeSpan.FromSeconds(60 - DateTime.UtcNow.Second), () =>
                {
                    UpdateTimeRemaining();
                    return(false);
                });
            }
        }
Ejemplo n.º 13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            storeService = new StoreService();
            cycleService = new CycleService();

            var cycles = cycleService.GetAllCycles().ToList().OrderBy(a => a.CycleYear).ThenBy(b => b.CycleNumber).ThenBy(c => c.ESP);

            if (cycles.Count() == 0)
            {
                Toast.MakeText(Application, "No Cycles! Loading Cycle Data!", ToastLength.Short).Show();

                cycleService.LoadCycles();
                cycles = cycleService.GetAllCycles().ToList().OrderBy(a => a.CycleYear).ThenBy(b => b.CycleNumber).ThenBy(c => c.ESP);
            }
            else
            {
                Toast.MakeText(Application, "Retrieving data from existing Realm!", ToastLength.Short).Show();
            }

            var stores = storeService.GetAllStores().ToList().OrderBy(s => s.AcostaNumber).ToList();

            if (stores.Count() == 0)
            {
                Toast.MakeText(Application, "No Stores! Loading Store Data!", ToastLength.Short).Show();
                storeService.LoadStores();
                stores = storeService.GetAllStores().ToList().OrderBy(s => s.AcostaNumber).ToList();
            }
            else
            {
                Toast.MakeText(Application, "Retrieving store data from existing Realm!", ToastLength.Short).Show();
            }

            //string[] cycleNames = cycles.Select(x => x.CycleYear.ToString() + x.CycleNumber.ToString() + x.ESP + "::" + x.Id.ToString()).ToArray<string>();



            //ListAdapter = new ArrayAdapter<string>(this, Resource.Layout.list_item, cycleNames);
            //ListView.TextFilterEnabled = true;

            //ListView.ItemClick += delegate (object sender, AdapterView.ItemClickEventArgs args)
            //{
            //    string cycletext = ((TextView)args.View).Text;
            //    string[] aCycleText = cycletext.Split(new string[1] { "::" }, StringSplitOptions.RemoveEmptyEntries);
            //    int cycleId = 0;

            //    if(Int32.TryParse(aCycleText[1], out cycleId))
            //    {
            //        ShowCycleDetails(cycleId);
            //    }
            //};

            ListAdapter = new StoresAdapter(this, stores);

            ListView.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args)
            {
                var    item          = ((StoresAdapter)ListAdapter).GetItemAtPosition(args.Position);
                string messageFormat = "{0}\n{1} : {2}\n{3}\n{4}, {5} {6}\n{7}";
                long   phone         = 0;
                Int64.TryParse(item.StorePhone, out phone);
                string phoneNumber = string.Format("{0:(###)###-####}", phone);
                long   izip        = 0;
                Int64.TryParse(item.StoreZip, out izip);
                string szip          = string.Format("{0:#####-####}", izip);
                string dialogMessage = string.Format(messageFormat, item.AcostaNumber, item.StoreName, item.StoreNumber, item.StoreAddress, item.StoreCity, item.StoreState, szip, phoneNumber);

                Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);
                alert.SetTitle("Store Details");
                alert.SetMessage(dialogMessage);
                alert.SetPositiveButton("OK", (senderAlert, e) => { /*just want to dismiss the dialog, not do anything else!*/ });
                Dialog dialog = alert.Create();
                dialog.Show();
            };
        }
Ejemplo n.º 14
0
        private async void GetStandingsAsync(bool ignoreCache = false)
        {
            int cycleNo = 0;

            if (!string.IsNullOrWhiteSpace(Cycle))
            {
                int p = Cycle.IndexOf(" ") + 1;
                Int32.TryParse(Cycle.Substring(p, Cycle.Length - p), out cycleNo);
            }

            if ((Standings?.Any() == false) || (cycleNo != CycleService.CurrentCycle() && (LastUpdated + TimeSpan.FromMinutes(10) < DateTime.Now)))
            {
                ShowMessage = false;
                CancellationTokenSource cancelToken = new CancellationTokenSource();

                using (UserDialogs.Instance.Loading("Loading", () => cancelToken.Cancel(), null, true, MaskType.Clear))
                {
                    try
                    {
                        // get the standings
                        StandingsService  standingsService = StandingsService.Instance();
                        GalacticStandings standings        = await standingsService.GetData(cancelToken, ignoreCache).ConfigureAwait(false);

                        Cycle       = $"Cycle {standings.Cycle}";
                        LastUpdated = standings.LastUpdated;

                        if (standings.Standings.Count < 1)
                        {
                            SetMessages("Unable to display Powerplay Standings due to parsing error.", true);
                        }
                        else
                        {
                            // show the standings
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                Standings.Clear();
                                foreach (PowerStanding item in standings.Standings)
                                {
                                    Standings.Add(item);
                                }
                            });
                        }
                    }
                    catch (OperationCanceledException)
                    {
                        SetMessages("Powerplay Standings download was cancelled or timed out.", true);
                    }
                    catch (HttpRequestException ex)
                    {
                        string err   = ex.Message;
                        int    start = err.IndexOf("OPENSSL_internal:", StringComparison.OrdinalIgnoreCase);
                        if (start > 0)
                        {
                            start += 17;
                            int end = err.IndexOf(" ", start, StringComparison.OrdinalIgnoreCase);
                            err = $"SSL Error ({err.Substring(start, end - start).Trim()})";
                        }
                        else if (err.IndexOf("Error:", StringComparison.OrdinalIgnoreCase) > 0)
                        {
                            err = err.Substring(err.IndexOf("Error:", StringComparison.OrdinalIgnoreCase) + 6).Trim();
                        }
                        SetMessages($"Network Error: {err}", true);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("unexpected end of stream"))
                        {
                            SetMessages("Powerplay Standings download was cancelled.", true);
                        }
                        else
                        {
                            SetMessages($"Error: {ex.Message}", true);
                        }
                    }
                }
            }
        }