Exemple #1
0
        async void ExecuteLoadItemsCommand()
        {
            await Task.Delay(200);

            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Items.Clear();
                var mahasiswa = await UserService.GetProfile(Helper.Account.Role);

                var items = await KrsServices.GetJadwal(mahasiswa);

                var source            = items.GroupBy(x => x.Hari);
                List <DayOfWeek> days = new List <DayOfWeek>()
                {
                    DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday
                };
                CultureInfo cultureinfo = new CultureInfo("id-ID");
                foreach (var day in days)
                {
                    var hari  = cultureinfo.DateTimeFormat.GetDayName(day);
                    var datas = source.Where(x => x.Key.ToLower() == hari.ToLower()).FirstOrDefault();
                    if (datas != null)
                    {
                        GroupJadwal d = new GroupJadwal(hari);
                        if (d != null)
                        {
                            foreach (var item in datas.ToList())
                            {
                                d.Add(item);
                            }
                            Items.Add(d);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                await Task.Delay(200);

                IsBusy = false;
            }
        }
Exemple #2
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                try
                {
                    Items.Clear();

                    Pengumuman = Helper.Inboxs.Current;

                    var mahasiswa = await UserService.GetProfile(Helper.Account.Role);

                    var items = await KrsServices.GetJadwal(mahasiswa);

                    if (items != null && items.Count > 0)
                    {
                        var cultureinfo   = new System.Globalization.CultureInfo("id-ID");
                        var day           = cultureinfo.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek);
                        var jadwalHariini = items.Where(x => x.Hari.ToLower() == day.ToLower());
                        foreach (var item in jadwalHariini)
                        {
                            Items.Add(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessagingCenter.Send(new MessagingCenterAlert {
                        Title = "Info", Message = ex.Message, Cancel = "OK"
                    }, "messagse");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                await Task.Delay(200);

                IsBusy = false;
            }
        }