コード例 #1
0
        /// <summary>
        /// The update status action result
        /// </summary>
        /// <param name="id">the id of the order being updated</param>
        /// <returns>the update status page with an error message if something went wrong</returns>
        public IActionResult UpdateStatus(int?id)
        {
            RentalItem item = new RentalItem();

            try
            {
                Statuses.Clear();
                Conditions.Clear();

                item = this.rentalDal.RetrieveAllRentedItems().First(currentItem => currentItem.RentalId == id);
                var statuses = RentalItem.GetPossibleStatuses(item.Status);
                foreach (var current in statuses)
                {
                    Statuses.Add(new SelectListItem(current, current));
                }

                var conditions = InventoryItem.ConditionOptions;
                Conditions.Add(new SelectListItem(null, null));
                foreach (var current in conditions)
                {
                    Conditions.Add(new SelectListItem(current, current));
                }

                item.Condition = "";
            }
            catch (Exception)
            {
                ViewBag.ErrorMessage = "Uh-oh something went wrong";
            }


            return(View(item));
        }
コード例 #2
0
        public void TestGetPossibleStatusesWithReturned()
        {
            var expected = new List <string> {
                "Returned"
            };
            var actual = RentalItem.GetPossibleStatuses("Returned");

            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected[0], actual[0]);
        }
コード例 #3
0
        public void TestGetPossibleStatusesWithOrdered()
        {
            var expected = new List <string> {
                "Ordered", "Shipped"
            };
            var actual = RentalItem.GetPossibleStatuses("Ordered");

            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
        }
コード例 #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var oldViewModel = (MainPageViewModel)e.Parameter;

            this.ViewModel.CurrentEmployee = oldViewModel?.CurrentEmployee;
            this.ViewModel.SelectedRental  = oldViewModel?.SelectedRental;

            this.StatusTypes          = new ObservableCollection <string>(RentalItem.GetPossibleStatuses(this.ViewModel?.SelectedRental?.Status));
            this.comboBox.ItemsSource = this.StatusTypes;

            var conditionOptions = new ObservableCollection <string>();

            conditionOptions.Add("Select Condition");
            InventoryItem.ConditionOptions.ForEach(current => conditionOptions.Add(current));
            this.conditionComboBox.ItemsSource = new ObservableCollection <string>(conditionOptions);
        }