Пример #1
0
        public ActionResult DeleteConfirmed(string id)
        {
            try
            {
                ObjectId retnId = new ObjectId(id);
                RentRepository.DeleteRentById(retnId);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #2
0
        /// <summary>
        /// gets a rented item and delete it from db
        /// </summary>
        private void ReturnItem()
        {
            List <Rent> memberRents = ShowRents();

            int rentIdToReturn;

            while (true)
            {
                Console.Write("\nEnter RENT ID you want to DELETE: ");
                string inputRentId = Console.ReadLine();
                if (inputRentId.Length != 0 && IsDigitsOnly(inputRentId) && int.Parse(inputRentId) > 0 && int.Parse(inputRentId) <= memberRents.Count)
                {
                    rentIdToReturn = int.Parse(inputRentId) - 1;
                    break;
                }
            }

            RentRepository.DeleteRentById(memberRents[rentIdToReturn].Id);

            Console.WriteLine($"\nItem returned SUCCESSFULLY");

            PressKeyToGoBackToRentMenu();
        }