/// <summary>
        /// Returns an individual's unique assignment schedule list.
        /// </summary>
        /// <param name="groupGuid"></param>
        /// <returns>A list of <see cref="ListItemViewModel"/> to be passed into mobile.</returns>
        private List <ListItemViewModel> GetSpecificAssignmentScheduleList(Guid groupGuid)
        {
            using (var rockContext = new RockContext())
            {
                // Get the group.
                var group = new GroupService(rockContext).Get(groupGuid);

                var groupLocationService = new GroupLocationService(rockContext);
                var scheduleList         = groupLocationService
                                           .Queryable()
                                           .AsNoTracking()
                                           .Where(g => g.Group.Guid == groupGuid)
                                           .SelectMany(g => g.Schedules)
                                           .Distinct()
                                           .ToList();

                List <Schedule> sortedScheduleList = scheduleList.OrderByOrderAndNextScheduledDateTime();

                GroupMemberAssignmentService groupMemberAssignmentService = new GroupMemberAssignmentService(rockContext);
                int?groupMemberId = null;

                var groupMember = GetGroupMemberRecord(rockContext, group.Id, CurrentPersonId);
                if (groupMember != null)
                {
                    groupMemberId = groupMember.Id;
                }

                // Shouldn't happen, but we'll be cautious.
                if (!groupMemberId.HasValue)
                {
                    return(null);
                }

                var configuredScheduleIds = groupMemberAssignmentService.Queryable()
                                            .Where(a => a.GroupMemberId == groupMemberId.Value && a.ScheduleId.HasValue)
                                            .Select(s => s.ScheduleId.Value)
                                            .Distinct()
                                            .ToList();

                // Limit to schedules that haven't had a schedule preference set yet.
                sortedScheduleList = sortedScheduleList
                                     .Where(a => !configuredScheduleIds.Contains(a.Id))
                                     .ToList();

                var scheduleListItems = new List <ListItemViewModel>();

                foreach (var value in sortedScheduleList)
                {
                    var scheduleListItem = new ListItemViewModel
                    {
                        Value = value.Guid.ToStringSafe(),
                        Text  = value.Name
                    };

                    scheduleListItems.Add(scheduleListItem);
                }

                return(scheduleListItems);
            }
        }
        /// <summary>
        /// This takes the data that we get from the api and puts it into the ListItemViewModel.
        /// It then takes that data into the item page and displays the items.
        /// </summary>
        /// <returns>The TodoItem page</returns>
        public async Task <IActionResult> TodoItem()
        {
            using (var client = new HttpClient())
            {
                // add the appropriate properties on top of the client base address.
                client.BaseAddress = new Uri("https://lab17createanapi.azurewebsites.net/");

                //the .Result is important for us to extract the result of the response from the call
                var response     = client.GetAsync("/api/todoList").Result;
                var responseItem = client.GetAsync("/api/todoItem").Result;
                if (response.EnsureSuccessStatusCode().IsSuccessStatusCode)
                {
                    ListItemViewModel viewModel = new ListItemViewModel();
                    var stringResult            = await response.Content.ReadAsStringAsync();

                    viewModel.TodoLists = JsonConvert.DeserializeObject <List <TodoList> >(stringResult);
                    if (responseItem.EnsureSuccessStatusCode().IsSuccessStatusCode)
                    {
                        var result = await responseItem.Content.ReadAsStringAsync();

                        viewModel.TodoItems = JsonConvert.DeserializeObject <List <TodoItem> >(result);
                    }
                    return(View(viewModel));
                }
                return(BadRequest());
            }
        }
示例#3
0
        private void SortNPCs()
        {
            if (_npcs != null && _npcs.Count > 0)
            {
                List <NPCModel> npcs = _npcSearchService.Sort(_npcs.Select(x => x.Model), _npcSearchInput.SortOption.Key);
                for (int i = 0; i < npcs.Count; ++i)
                {
                    if (npcs[i].Id != _npcs[i].Model.Id)
                    {
                        ListItemViewModel <NPCModel> npc = _npcs.FirstOrDefault(x => x.Model.Id == npcs[i].Id);
                        if (npc != null)
                        {
                            _npcs.Move(_npcs.IndexOf(npc), i);
                        }
                    }
                }

                List <ListItemViewModel <NPCModel> > sorted = _npcs.OrderBy(x => x.Name).ToList();

                for (int i = 0; i < sorted.Count; ++i)
                {
                    if (!sorted[i].Equals(_npcs[i]))
                    {
                        _npcs.Move(_npcs.IndexOf(sorted[i]), i);
                    }
                }
            }
        }
示例#4
0
        private void SelectPrevious()
        {
            if (_locations.Any())
            {
                ListItemViewModel <LocationModel> selected = _locations.FirstOrDefault(x => x.IsSelected);

                foreach (ListItemViewModel <LocationModel> location in _locations)
                {
                    location.IsSelected = false;
                }

                if (selected == null)
                {
                    _locations[_locations.Count - 1].IsSelected = true;
                    _selectedLocation = new LocationViewModel(_locations[_locations.Count - 1].Model);
                }
                else
                {
                    int index = Math.Max(_locations.IndexOf(selected) - 1, 0);
                    _locations[index].IsSelected = true;
                    _selectedLocation            = new LocationViewModel(_locations[index].Model);
                }

                OnPropertyChanged(nameof(SelectedLocation));
            }
        }
示例#5
0
        private void SelectPrevious()
        {
            if (_tables.Any())
            {
                ListItemViewModel <RandomTableModel> selected = _tables.FirstOrDefault(x => x.IsSelected);

                foreach (ListItemViewModel <RandomTableModel> table in _tables)
                {
                    table.IsSelected = false;
                }

                if (selected == null)
                {
                    _tables[_tables.Count - 1].IsSelected = true;
                    _selectedTable = new RandomTableViewModel(_tables[_tables.Count - 1].Model);
                }
                else
                {
                    int index = Math.Max(_tables.IndexOf(selected) - 1, 0);
                    _tables[index].IsSelected = true;
                    _selectedTable            = new RandomTableViewModel(_tables[index].Model);
                }

                OnPropertyChanged(nameof(SelectedTable));
            }
        }
        public async Task ListItemViewModel_ItemTapped_ShouldThrowExceptionWithNullService()
        {
            #region Arrange

            var listViewModel = new ListItemViewModel(_apiClientMock.Object, null);
            await listViewModel.Initialized;

            var expectedItemViewModel = new ItemViewModel()
            {
                Title = "Test Item"
            };

            #endregion

            #region Act

// Calling th execute method cannot be asserted.
// Action command = () => listViewModel.ItemTapped.Execute(expectedItemViewModel);
            Func <Task> command = async() => await listViewModel.NavigateToItem(expectedItemViewModel);

            #endregion

            #region Assert

            await command.Should().ThrowAsync <InvalidOperationException>();

            #endregion
        }
示例#7
0
        private void InitializeListItemDetails(ListItemViewModel <RandomTableModel> listItem, RandomTableModel tableModel)
        {
            listItem.Model = tableModel;

            if (!String.IsNullOrWhiteSpace(tableModel.Name))
            {
                listItem.Name = tableModel.Name;
            }
            else
            {
                listItem.Name = "Unknown Name";
            }

            if (!String.IsNullOrWhiteSpace(tableModel.Die) && !String.IsNullOrWhiteSpace(tableModel.Header))
            {
                listItem.Description = $"{tableModel.Die}, {tableModel.Header}";
            }
            else if (String.IsNullOrWhiteSpace(tableModel.Die) && !String.IsNullOrWhiteSpace(tableModel.Header))
            {
                listItem.Description = $"Unknown Die, {tableModel.Header}";
            }
            else if (!String.IsNullOrWhiteSpace(tableModel.Die) && String.IsNullOrWhiteSpace(tableModel.Header))
            {
                listItem.Description = $"{tableModel.Die}, Unknown Header";
            }
            else
            {
                listItem.Description = "Unknown description";
            }
        }
示例#8
0
        private void Delete()
        {
            if (_selectedTable != null)
            {
                string message = String.Format("Are you sure you want to delete {0}?",
                                               _selectedTable.Name);

                bool?result = _dialogService.ShowConfirmationDialog("Delete Table", message, "Yes", "No", null);

                if (result == true)
                {
                    _compendium.DeleteTable(_selectedTable.RandomTableModel.Id);

                    ListItemViewModel <RandomTableModel> listItem = _tables.FirstOrDefault(x => x.Model.Id == _selectedTable.RandomTableModel.Id);
                    if (listItem != null)
                    {
                        _tables.Remove(listItem);
                    }

                    _selectedTable = null;

                    _compendium.SaveTables();

                    OnPropertyChanged(nameof(SelectedTagOption));
                    OnPropertyChanged(nameof(SelectedTable));

                    if (_tableEditViewModel != null)
                    {
                        CancelEditTable();
                    }
                }
            }
        }
示例#9
0
        private void SortTables()
        {
            if (_tables != null && _tables.Count > 0)
            {
                List <RandomTableModel> tables = _tableSearchService.Sort(_tables.Select(x => x.Model), _tableSearchInput.SortOption.Key);
                for (int i = 0; i < tables.Count; ++i)
                {
                    if (tables[i].Id != _tables[i].Model.Id)
                    {
                        ListItemViewModel <RandomTableModel> table = _tables.FirstOrDefault(x => x.Model.Id == tables[i].Id);
                        if (table != null)
                        {
                            _tables.Move(_tables.IndexOf(table), i);
                        }
                    }
                }

                List <ListItemViewModel <RandomTableModel> > sorted = _tables.OrderBy(x => x.Name).ToList();

                for (int i = 0; i < sorted.Count; ++i)
                {
                    if (!sorted[i].Equals(_tables[i]))
                    {
                        _tables.Move(_tables.IndexOf(sorted[i]), i);
                    }
                }
            }
        }
        private void SelectPrevious()
        {
            if (_adventures.Any())
            {
                ListItemViewModel <AdventureModel> selected = _adventures.FirstOrDefault(x => x.IsSelected);

                foreach (ListItemViewModel <AdventureModel> adventure in _adventures)
                {
                    adventure.IsSelected = false;
                }

                if (selected == null)
                {
                    _adventures[_adventures.Count - 1].IsSelected = true;
                    _selectedAdventure = new AdventureViewModel(_adventures[_adventures.Count - 1].Model);
                }
                else
                {
                    int index = Math.Max(_adventures.IndexOf(selected) - 1, 0);
                    _adventures[index].IsSelected = true;
                    _selectedAdventure            = new AdventureViewModel(_adventures[index].Model);
                }

                OnPropertyChanged(nameof(SelectedAdventure));
            }
        }
        private void SortAdventures()
        {
            if (_adventures != null && _adventures.Count > 0)
            {
                List <AdventureModel> adventures = _adventureSearchService.Sort(_adventures.Select(x => x.Model), _adventureSearchInput.SortOption.Key);
                for (int i = 0; i < adventures.Count; ++i)
                {
                    if (adventures[i].Id != _adventures[i].Model.Id)
                    {
                        ListItemViewModel <AdventureModel> adventure = _adventures.FirstOrDefault(x => x.Model.Id == adventures[i].Id);
                        if (adventure != null)
                        {
                            _adventures.Move(_adventures.IndexOf(adventure), i);
                        }
                    }
                }

                List <ListItemViewModel <AdventureModel> > sorted = _adventures.OrderBy(x => x.Name).ToList();

                for (int i = 0; i < sorted.Count; ++i)
                {
                    if (!sorted[i].Equals(_adventures[i]))
                    {
                        _adventures.Move(_adventures.IndexOf(sorted[i]), i);
                    }
                }
            }
        }
示例#12
0
        /// <summary>
        /// Creates a view model representation of a
        /// <see cref="Rock.Workflow.FormBuilder.FormNotificationEmailSettings"/> object.
        /// </summary>
        /// <param name="emailSettings">The object to be represented as a view model.</param>
        /// <param name="rockContext">The database context used for data lookups.</param>
        /// <returns>The view model representation.</returns>
        internal static FormNotificationEmailViewModel ToViewModel(this Rock.Workflow.FormBuilder.FormNotificationEmailSettings emailSettings, RockContext rockContext)
        {
            if (emailSettings == null || !emailSettings.Enabled)
            {
                return(new FormNotificationEmailViewModel());
            }

            ListItemViewModel recipient = null;

            if (emailSettings.RecipientAliasId.HasValue)
            {
                var person = new PersonAliasService(rockContext).GetPerson(emailSettings.RecipientAliasId.Value);

                if (person != null)
                {
                    recipient = new ListItemViewModel
                    {
                        Value = person.Guid.ToString(),
                        Text  = person.FullName
                    };
                }
            }

            return(new FormNotificationEmailViewModel
            {
                Enabled = emailSettings.Enabled,
                CampusTopicGuid = Utility.GetDefinedValueGuid(emailSettings.CampusTopicValueId),
                Destination = ToViewModel(emailSettings.Destination),
                EmailAddress = emailSettings.EmailAddress,
                Recipient = recipient,
                Source = ToViewModel(emailSettings.Source, rockContext)
            });
        }
        public async Task ListItemViewModel_Constructor_InitializeWithData()
        {
            //var expectedResults = _fixture.CreateMany<Product>(9);

            #region Arrange

            var target = _fixture.Create <ListItemViewModel>();

            //var expectedResults = new List<Product>();
            //expectedResults.Add(new Product { Title = "testProduct", Description = "testDescription" });

            // Using the mock setup for the IApiClient
            //_apiClientMock.Setup(client => client.RetrieveProductsAsync()).ReturnsAsync(expectedResults);

            #endregion

            #region Act

            var listViewModel = new ListItemViewModel(_apiClientMock.Object, null);
            await listViewModel.Initialized;

            #endregion

            #region Assert

            listViewModel.Items.Should().HaveCount(_expectedProductData.Count());
            listViewModel.ItemTapped.Should().NotBeNull()
            .And.Subject.Should().BeOfType <Command <ItemViewModel> >();

            _apiClientMock.Verify(client => client.RetrieveProductsAsync());

            #endregion
        }
示例#14
0
        private void InitializeListItemDetails(ListItemViewModel <LocationModel> listItem, LocationModel locationModel)
        {
            listItem.Model = locationModel;

            if (!String.IsNullOrWhiteSpace(locationModel.Name))
            {
                listItem.Name = locationModel.Name;
            }
            else
            {
                listItem.Name = "Unknown Name";
            }

            if (!String.IsNullOrWhiteSpace(locationModel.Description))
            {
                if (locationModel.Description.Length > 50)
                {
                    listItem.Description = new String(locationModel.Description.Take(50).ToArray()) + "...";
                }
                else
                {
                    listItem.Description = locationModel.Description;
                }
            }
            else
            {
                listItem.Description = "Unknown description";
            }
        }
示例#15
0
        async private void DeleteAllButton_Click(object sender, RoutedEventArgs e)
        {
            ContentDialog DeleteAllConfirm = new ContentDialog
            {
                Title             = "Warning",
                Content           = "If you delete all the items, you won't be able to recover it. You sure to delete all?",
                PrimaryButtonText = "Delete",
                CloseButtonText   = "Cancel"
            };
            ContentDialogResult result = await DeleteAllConfirm.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                if (ListItemViewModel.GetViewModel().AllItems.Count == 0)
                {
                    NoneEventError();
                }
                else
                {
                    ListItemViewModel.GetViewModel().RemoveAllListItem();
                    DeleteAll_Succeed();
                    ListItemViewModel.GetViewModel().selectedItem = null;
                    title.Text       = detail.Text = "";
                    date_picker.Date = DateTime.Now;
                    create.Content   = "Create";
                    //source = null;
                    OpenFileWriteBit();
                    picture.Source = new BitmapImage(new Uri("ms-appx:/Assets/BackGroud.jpg", UriKind.RelativeOrAbsolute));
                    TileService.UpdateTiles();
                }
            }
            else
            {
            }
        }
        public ActionResult ListItem(Int32?Page, String Description, Int32?FatherId)
        {
            var model = new ListItemViewModel();

            model.Fill(CargarDatosContext(), Page, Description, FatherId);
            return(View(model));
        }
示例#17
0
        private void Delete()
        {
            if (_selectedLocation != null)
            {
                string message = String.Format("Are you sure you want to delete {0}?", _selectedLocation.Name);

                bool?result = _dialogService.ShowConfirmationDialog("Delete Location", message, "Yes", "No", null);

                if (result == true)
                {
                    _compendium.DeleteLocation(_selectedLocation.LocationModel.Id);

                    ListItemViewModel <LocationModel> listItem = _locations.FirstOrDefault(x => x.Model.Id == _selectedLocation.LocationModel.Id);
                    if (listItem != null)
                    {
                        _locations.Remove(listItem);
                    }

                    _selectedLocation = null;

                    _compendium.SaveLocations();

                    OnPropertyChanged(nameof(SelectedLocation));

                    if (_locationEditViewModel != null)
                    {
                        CancelEditLocation();
                    }
                }
            }
        }
示例#18
0
        private void Button_Click_Create(object sender, RoutedEventArgs e)
        {
            int year  = date_picker.Date.Year;
            int month = date_picker.Date.Month;
            int day   = date_picker.Date.Day;

            if (title.Text == "" || detail.Text == "")
            {
                Empty_Text();
            }
            else if (!Valid_Date(year, month, day))
            {
                InValid_Date_Input();
            }
            else
            {
                if ((string)create.Content == "Create")
                {
                    ListItemViewModel.GetViewModel().AddListItem(title.Text, detail.Text, new DateTime(year, month, day), source);
                    Create_Succeed();
                }
                else if ((string)create.Content == "Update")
                {
                    ListItemViewModel.GetViewModel().UpdateListItem(ListItemViewModel.GetViewModel().selectedItem.GetID(), title.Text, detail.Text, new DateTime(year, month, day), source);
                    Update_Succeed();
                }
                TileService.UpdateTiles();
                title.Text       = detail.Text = "";
                date_picker.Date = DateTime.Now;
                create.Content   = "Create";
                OpenFileWriteBit();
                picture.Source = new BitmapImage(new Uri("ms-appx:/Assets/BackGroud.jpg", UriKind.RelativeOrAbsolute));
                this.Frame.GoBack();
            }
        }
示例#19
0
        private void SortLocations()
        {
            if (_locations != null && _locations.Count > 0)
            {
                List <LocationModel> locations = _locationSearchService.Sort(_locations.Select(x => x.Model), _locationSearchInput.SortOption.Key);
                for (int i = 0; i < locations.Count; ++i)
                {
                    if (locations[i].Id != _locations[i].Model.Id)
                    {
                        ListItemViewModel <LocationModel> location = _locations.FirstOrDefault(x => x.Model.Id == locations[i].Id);
                        if (location != null)
                        {
                            _locations.Move(_locations.IndexOf(location), i);
                        }
                    }
                }

                List <ListItemViewModel <LocationModel> > sorted = _locations.OrderBy(x => x.Name).ToList();

                for (int i = 0; i < sorted.Count; ++i)
                {
                    if (!sorted[i].Equals(_locations[i]))
                    {
                        _locations.Move(_locations.IndexOf(sorted[i]), i);
                    }
                }
            }
        }
示例#20
0
        private void SelectPrevious()
        {
            if (_npcs.Any())
            {
                ListItemViewModel <NPCModel> selected = _npcs.FirstOrDefault(x => x.IsSelected);

                foreach (ListItemViewModel <NPCModel> npc in _npcs)
                {
                    npc.IsSelected = false;
                }

                if (selected == null)
                {
                    _npcs[_npcs.Count - 1].IsSelected = true;
                    _selectedNPC = new NPCViewModel(_npcs[_npcs.Count - 1].Model);
                }
                else
                {
                    int index = Math.Max(_npcs.IndexOf(selected) - 1, 0);
                    _npcs[index].IsSelected = true;
                    _selectedNPC            = new NPCViewModel(_npcs[index].Model);
                }

                OnPropertyChanged(nameof(SelectedNPC));
            }
        }
示例#21
0
 public ListSearchResultViewModel(ListItemViewModel item)
 {
     this.Item          = item;
     this.Title         = item.Item.Title;
     this.OriginalTitle = item.Item.OriginalTitle;
     this.Year          = item.Item.Year;
     this.Tag           = item.Item is MovieListItem?nameof(Movie) : nameof(Series);
 }
 private void MoveToLeft(ListItemViewModel item)
 {
     if (item != null)
     {
         RightItems.Remove(item);
         LeftItems.Add(item);
     }
 }
示例#23
0
        void RemoveItem(ListItemViewModel item)
        {
            var todoItem = todos.SingleOrDefault(t => t.Id == item.Id);

            if (todoItem != null)
            {
                todos.Remove(todoItem);
            }
        }
示例#24
0
 private void DeleteButton_Click(object sender, RoutedEventArgs e)
 {
     if (ListItemViewModel.GetViewModel().selectedItem != null)
     {
         ListItemViewModel.GetViewModel().RemoveListItem(ListItemViewModel.GetViewModel().selectedItem.GetID());
         TileService.UpdateTiles();
         Delete_Succeed();
         this.Frame.GoBack();
     }
 }
示例#25
0
 private void Button_Click_Cancel(object sender, RoutedEventArgs e)
 {
     title.Text       = detail.Text = "";
     date_picker.Date = DateTime.Now;
     create.Content   = "Create";
     ListItemViewModel.GetViewModel().selectedItem = null;
     OpenFileWriteBit();
     picture.Source = new BitmapImage(new Uri("ms-appx:/Assets/BackGroud.jpg", UriKind.RelativeOrAbsolute));
     this.Frame.GoBack();
 }
示例#26
0
        //Do not set All Parameters
        public static SortedListItem ConvertToSortedListItem(this ListItemViewModel ViewModel, int i)
        {
            SortedListItem result = new SortedListItem
            {
                ListItemID   = ViewModel.ID,
                SortedNumber = i
            };

            return(result);
        }
示例#27
0
        public ActionResult Delete(ListItemViewModel model)
        {
            using (POSContext context = new POSContext())
            {
                using (var dbTransaction = context.Database.BeginTransaction())
                {
                    int UserId   = User.Identity.GetUserId <int>();
                    int OutletId = 0;
                    OutletId = (int)EmployeeOutletDAL.GetDataOutletByUserId(UserId).OutletID;

                    int i = 0;
                    foreach (var item in model.InventoryId)
                    {
                        ItemsIventory data3 = context.TItemsIventory.Where(x => x.ID == item).FirstOrDefault();

                        context.TItemsIventory.Remove(data3);
                        try { context.SaveChanges(); }
                        catch (Exception) { }
                        i++;
                    }

                    i = 0;
                    foreach (var item in model.VariantId)
                    {
                        ItemsVariant data2 = context.TItemsVariant.Where(x => x.ID == item).FirstOrDefault();

                        context.TItemsVariant.Remove(data2);
                        try { context.SaveChanges(); }
                        catch (Exception) { }

                        i++;
                    }

                    Items data = context.TItems.Where(x => x.ID == model.ID).FirstOrDefault();

                    context.TItems.Remove(data);

                    try { context.SaveChanges(); }
                    catch (Exception) { }


                    try
                    {
                        dbTransaction.Commit();
                        return(RedirectToAction("Index"));
                    }
                    catch (Exception)
                    {
                        dbTransaction.Rollback();
                    }
                }
            }

            return(PartialView("Delete", model));
        }
示例#28
0
        public ActionResult Delete(int Id)
        {
            //list Category
            ViewBag.listCategories = new SelectList(CategoriesDAL.GetData(), "ID", "Name");
            //list Inventory
            ViewBag.listInventory = new SelectList(ItemsIventoryDAL.GetData(), "ID", "VariantName");

            ListItemViewModel model = ItemsDAL.GetDataById(Id);

            return(PartialView("Delete", model));
        }
        public static SelectListItem ConvertToSelectListItem(this ListItemViewModel item)
        {
            var result = new SelectListItem()
            {
                Value    = item.Value.ToString(),
                Text     = item.Text,
                Selected = item.Select
            };

            return(result);
        }
示例#30
0
        public static ListItem ConvertToListItem(this ListItemViewModel ViewModel, int numberInList)
        {
            ListItem result = new ListItem
            {
                Description  = ViewModel.Description,
                ImageString  = ViewModel.ImageString,
                Name         = ViewModel.Name,
                NumberInList = numberInList
            };

            return(result);
        }