Exemplo n.º 1
0
        public ActionResult About()
        {
            var data = from student in db.Students
                       group student by student.Birth into DateGroup
                       select new BirthDateGroup()
            {
                Birth        = DateGroup.Key,
                StudentCount = DateGroup.Count()
            };

            return(View(data.ToList()));
        }
Exemplo n.º 2
0
        private DateGroup GetGroupFor(TimeEntryData dataObject)
        {
            var date = dataObject.StartTime.ToLocalTime().Date;
            var grp  = dateGroups.FirstOrDefault(g => g.Date == date);

            if (grp == null)
            {
                grp = new DateGroup(date);
                dateGroups.Add(grp);
            }
            return(grp);
        }
        public ActionResult Stats()
        {
            IQueryable <EnrollmentDateGroup> data = from student in db.Students
                                                    group student by student.EnrollmentDate into DateGroup
                                                    select new EnrollmentDateGroup()
            {
                EnrollmentDate = DateGroup.Key,
                StudentCount   = DateGroup.Count()
            };

            return(View(data.ToList()));
        }
Exemplo n.º 4
0
        private int GetDateGroupIndex(DateGroup dateGroup)
        {
            var count = 0;

            foreach (var grp in dateGroups)
            {
                if (grp.Date == dateGroup.Date)
                {
                    return(count);
                }
                count += grp.TimeEntryGroupList.Count + 1;
            }
            return(-1);
        }
Exemplo n.º 5
0
        private DateGroup GetDateGroupFor(TimeEntryData dataObject, out bool isNewDateGroup)
        {
            isNewDateGroup = false;
            var date      = dataObject.StartTime.ToLocalTime().Date;
            var dateGroup = dateGroups.FirstOrDefault(g => g.Date == date);

            if (dateGroup == null)
            {
                dateGroup = new DateGroup(date);
                dateGroups.Add(dateGroup);
                isNewDateGroup = true;
            }
            return(dateGroup);
        }
Exemplo n.º 6
0
        private TimeEntryGroup GetSuitableEntryGroupFor(DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup)
        {
            isNewEntryGroup = false;

            foreach (var grp in dateGroup.TimeEntryGroupList)
            {
                if (grp.CanContain(dataObject))
                {
                    return(grp);
                }
            }

            var entryGroup = new TimeEntryGroup(dataObject);

            dateGroup.Add(entryGroup);
            isNewEntryGroup = true;

            return(entryGroup);
        }
Exemplo n.º 7
0
        private bool FindExistingEntry(TimeEntryData dataObject, out DateGroup dateGroup, out TimeEntryData existingDataObject)
        {
            foreach (var grp in dateGroups)
            {
                foreach (var obj in grp.DataObjects)
                {
                    if (dataObject.Matches(obj))
                    {
                        dateGroup          = grp;
                        existingDataObject = obj;
                        return(true);
                    }
                }
            }

            dateGroup          = null;
            existingDataObject = null;
            return(false);
        }
Exemplo n.º 8
0
        private TimeEntryGroup GetExistingEntryGroupFor(DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup)
        {
            isNewEntryGroup = false;

            foreach (var grp in dateGroup.TimeEntryGroupList)
            {
                TimeEntryData entryData;
                if (grp.Contains(dataObject, out entryData))
                {
                    return(grp);
                }
            }

            var entryGroup = new TimeEntryGroup(dataObject);

            dateGroup.Add(entryGroup);
            isNewEntryGroup = true;

            return(entryGroup);
        }
Exemplo n.º 9
0
        protected async override Task AddTimeEntryHolderAsync(TimeEntryHolder holder)
        {
            var entryGroup = new TimeEntryGroup(holder.TimeEntryDataList);

            bool      isNewGroup;
            DateGroup grp = GetDateGroupFor(entryGroup.Data, out isNewGroup);

            grp.Add(entryGroup);
            Sort();

            // Update Date group.
            var groupIndex  = GetDateGroupIndex(grp);
            var groupAction = isNewGroup ? NotifyCollectionChangedAction.Add : NotifyCollectionChangedAction.Replace;

            await UpdateCollectionAsync(grp, groupAction, groupIndex);

            // Add time entry group.
            var newIndex = GetEntryGroupIndex(entryGroup);

            await UpdateCollectionAsync(entryGroup, NotifyCollectionChangedAction.Add, newIndex);
        }
Exemplo n.º 10
0
    public void Execute()
    {
        var      dateTimeFormat = CultureInfo.GetCultureInfo("en-US").DateTimeFormat;
        var      dates          = new[] { "11/15/2010", "12/1/10", "12/2/10", "12/3/10", "12/4/10", "12/9/10" };
        var      realDates      = dates.Select(s => DateTime.Parse(s, dateTimeFormat));
        var      dateGroups     = new List <DateGroup>();
        DateTime lastDate       = DateTime.MinValue;

        foreach (var date in realDates.OrderBy(d => d))
        {
            if (date.Month == lastDate.Month && (date - lastDate).Days <= 1)
            {
                var dateGroup = dateGroups.LastOrDefault();
                dateGroup.Dates.Add(date);
            }
            else
            {
                var dateGroup = new DateGroup();
                dateGroups.Add(dateGroup);
                dateGroup.Dates.Add(date);
            }
            lastDate = date;
        }
        foreach (var dateGroup in dateGroups)
        {
            if (dateGroup.Dates.Count == 1)
            {
                Console.WriteLine(dateGroup.First.ToString(dateTimeFormat.ShortDatePattern, dateTimeFormat));
            }
            else
            {
                int firstDay   = dateGroup.First.Day;
                int lastDay    = dateGroup.Last.Day;
                var dateString = dateTimeFormat.ShortDatePattern.Replace("d", firstDay + "-" + lastDay);
                Console.WriteLine(dateGroup.First.ToString(dateString, dateTimeFormat));
            }
        }
        Console.ReadLine();
    }
Exemplo n.º 11
0
        private bool FindExistingEntry(TimeEntryData dataObject, out DateGroup dateGroup, out TimeEntryGroup existingGroup, out TimeEntryData existingEntry)
        {
            foreach (var grp in dateGroups)
            {
                foreach (var obj in grp.TimeEntryGroupList)
                {
                    TimeEntryData entry;
                    if (obj.Contains(dataObject, out entry))
                    {
                        dateGroup     = grp;
                        existingGroup = obj;
                        existingEntry = entry;
                        return(true);
                    }
                }
            }

            existingEntry = null;
            dateGroup     = null;
            existingGroup = null;
            return(false);
        }
        private void PopulateBettingHistory(DateGroup group)
        {
            foreach (var match in group.Matches)
            {
                if (match.Result != null && match.Prediction != null)
                {
                    var betDate = match.KickoffDate;
                    ProcessPendingBets(betDate);

                    var odds           = match.Prediction.PredictedResultOdds;
                    var amount         = bettingHistory.Balance / 3;
                    var amountToReturn = amount * odds;
                    var cashoutDate    = match.KickoffDate.AddMinutes(115);

                    var bet = new Bet()
                    {
                        Count            = 1,
                        Odds             = odds,
                        BalanceBeforeBet = bettingHistory.Balance,
                        Amount           = amount,
                        AmountToReturn   = amountToReturn,
                        BetDate          = betDate,
                        CashoutDate      = cashoutDate,
                        Matches          = new Collection <ItemMatch>()
                        {
                            match
                        }
                    };

                    bettingHistory.Count += 1;
                    bettingHistory.Bets.Add(bet);
                    bettingHistory.Balance -= bet.Amount;
                }
            }

            ProcessPendingBets();
        }
        private bool FindExistingEntry (TimeEntryData dataObject, out DateGroup dateGroup, out TimeEntryGroup existingGroup, out TimeEntryData existingEntry)
        {
            foreach (var grp in dateGroups) {
                foreach (var obj in grp.TimeEntryGroupList) {
                    TimeEntryData entry;
                    if (obj.Contains (dataObject, out entry)) {
                        dateGroup = grp;
                        existingGroup = obj;
                        existingEntry = entry;
                        return true;
                    }
                }
            }

            existingEntry = null;
            dateGroup = null;
            existingGroup = null;
            return false;
        }
Exemplo n.º 14
0
        void LoadTransactions(int offset)
        {
            try
            {
                isLoading = true;
                string transactionsInfo = "";
                transactions.Amount    = _amount;
                transactions.DeviceKey = MobileStaticVariables.UserInfo.MobileDeviceKey;
                transactions.Offset    = offset;
                transactionsInfo       = MobileStaticVariables.WebUtils.SendCardRequest("TransactionsSeller", Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(transactions))));

                Logger.WriteLine("transactionsInfo : " + transactionsInfo);
                if (transactionsInfo == "")
                {
                    throw new Exception("Pustaya stroka");
                }
                transactions = JsonConvert.DeserializeObject <SellerTransactionInfo>(transactionsInfo);
                if (transactions.ResultState == RequestResult.Results.Success)
                {
                    if (offset == 0 && transactions.Transactions.Count == 0)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            HideList();
                        });
                    }
                }
                else
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        if (IsVisible)
                        {
                            await DisplayAlert("Внимание", transactions.TranslateResult(transactions.ResultState), "Продолжить");
                            HideList();
                        }
                    });
                }

                Device.BeginInvokeOnMainThread(() =>
                {
                    foreach (var item in transactions.Transactions)
                    {
                        var transactionCellView = new CellModel(item);
                        var group = Transactions.FirstOrDefault(x => (x.ComleteDate.Year == item.CompleteDatetime.Year) && (x.ComleteDate.DayOfYear == item.CompleteDatetime.DayOfYear));
                        if (group != null)
                        {
                            group.Add(transactionCellView);
                        }
                        else
                        {
                            var isFirstGroup = Transactions.Count == 0;
                            group            = new DateGroup(item.CompleteDatetime, _upFrame, isFirstGroup);
                            group.Add(transactionCellView);
                            Transactions.Add(group);
                        }
                    }
                    needToLoad = transactions.Transactions.Count == _amount;
                    if (IsVisible)
                    {
                        listTransaction.ItemsSource = null;
                        listTransaction.ItemsSource = Transactions;
                    }
                });
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex);
                Device.BeginInvokeOnMainThread(() =>
                {
                    if (IsVisible)
                    {
                        HideList();
                        noConnectionLayout.IsVisible = true;
                        Device.StartTimer(new TimeSpan(0, 0, 1), WaitInternetConnection);
                    }
                });
            }
            finally
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    EndLoading();
                });
                isLoading = false;
            }
        }
        private TimeEntryGroup GetExistingEntryGroupFor (DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup)
        {
            isNewEntryGroup = false;

            foreach (var grp in dateGroup.TimeEntryGroupList) {
                TimeEntryData entryData;
                if (grp.Contains (dataObject, out entryData)) {
                    return grp;
                }
            }

            var entryGroup = new TimeEntryGroup (dataObject);
            dateGroup.Add (entryGroup);
            isNewEntryGroup = true;

            return entryGroup;
        }
Exemplo n.º 16
0
 private DateGroup GetGroupFor (TimeEntryData dataObject, out bool isNewGroup)
 {
     isNewGroup = false;
     var date = dataObject.StartTime.ToLocalTime ().Date;
     var grp = dateGroups.FirstOrDefault (g => g.Date == date);
     if (grp == null) {
         grp = new DateGroup (date);
         dateGroups.Add (grp);
         isNewGroup = true;
     }
     return grp;
 }
Exemplo n.º 17
0
 private int GetDateGroupIndex (DateGroup dateGroup)
 {
     var count = 0;
     foreach (var grp in dateGroups) {
         if (grp.Date == dateGroup.Date) {
             return count;
         }
         count += grp.TimeEntryList.Count + 1;
     }
     return -1;
 }
Exemplo n.º 18
0
        private bool FindExistingEntry (TimeEntryData dataObject, out DateGroup dateGroup, out TimeEntryData existingDataObject)
        {
            foreach (var grp in dateGroups) {
                foreach (var obj in grp.TimeEntryList) {
                    if (dataObject.Matches (obj)) {
                        dateGroup = grp;
                        existingDataObject = obj;
                        return true;
                    }
                }
            }

            dateGroup = null;
            existingDataObject = null;
            return false;
        }
        private TimeEntryGroup GetSuitableEntryGroupFor (DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup)
        {
            isNewEntryGroup = false;

            foreach (var grp in dateGroup.TimeEntryGroupList) {
                if (grp.CanContain (dataObject)) {
                    return grp;
                }
            }

            var entryGroup = new TimeEntryGroup (dataObject);
            dateGroup.Add (entryGroup);
            isNewEntryGroup = true;

            return entryGroup;
        }