public ActionResult Create(Room room)
        {
            if (!ModelState.IsValid)
            {
                return(View(room));
            }
            bool Succeded = RoomService.AddItem(room);

            if (Succeded)
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.list = new SelectList(BranchService.GetAllItems(), "BranchId", "Name");
            return(View());
        }
        // GET api/values/5
        public async Task <string> Get(int id)
        {
            var sw = System.Diagnostics.Stopwatch.StartNew();

            for (int i = 0; i < id; i++)
            {
                var model = new MyModel
                {
                    Id         = 1,
                    FirstName  = "John",
                    MiddleName = "L",
                    LastName   = "Doe",
                    Age        = 20
                };
                await _rentalService.AddItem(Defaults.CreateListing());
            }
            return($"Added {id} items in {sw.Elapsed.Seconds} seconds.");
        }
예제 #3
0
        public int AddNewExercise()
        {
            var addNewExerciseMenu = _actionService.GetMenuActionsByMenuName("AddNewExerciseMenu");


            var menuActionsToShow = new List <string>();

            addNewExerciseMenu.ForEach(menuAction => menuActionsToShow.Add($"{menuAction.Id}. {menuAction.Name}"));

            _informationProvider.ShowMultipleInformation(menuActionsToShow);

            bool isValidInput = false;
            int  typeId       = 0;

            while (!isValidInput)
            {
                _informationProvider.ShowSingleMessage("Please select exercise type:");

                typeId = _informationProvider.GetNumericInputKey();

                isValidInput = typeId != 0 && typeId <= menuActionsToShow.Count;
            }

            isValidInput = false;
            string name = string.Empty;

            while (!isValidInput)
            {
                _informationProvider.ShowSingleMessage("\nPlease insert name for item: ");

                name = _informationProvider.GetInputString();

                isValidInput = !string.IsNullOrWhiteSpace(name);
            }

            var lastId = _exerciseService.GetLastId();

            var exercise = new Exercise(lastId + 1, name, typeId);

            _exerciseService.AddItem(exercise);

            return(exercise.Id);
        }
예제 #4
0
        //public void AddNewItem()
        //{
        //    var addNewItemMenu = _actionService.GetMenuActionsByMenuName("AddNewItemMenu");
        //    Console.WriteLine("Wybierz typ pliku:");
        //    for (int i = 0; i < addNewItemMenu.Count; i++)
        //    {
        //        Console.WriteLine($"{addNewItemMenu[i].Id}. {addNewItemMenu[i].Name}");
        //    }
        //    int lastId = _itemService.GetLastId();
        //    var operation = Console.ReadKey();
        //    Int32.TryParse(operation.KeyChar.ToString(), out int typeId);
        //    Console.WriteLine("Podaj nazwe pliku:");
        //    var name = Console.ReadLine();

        //    Item item = new Item(lastId+1,name.ToString(), typeId);

        //    Items.Add(item);


        //}
        public int AddNewItem()
        {
            var addNewItemMenu = _actionService.GetMenuActionsByMenuName("AddNewItemMenu");

            Console.WriteLine("Podaj typ pliku:");
            for (int i = 0; i < addNewItemMenu.Count; i++)
            {
                Console.WriteLine($"{addNewItemMenu[i].Id}. {addNewItemMenu[i].Name}");
            }

            var operation = Console.ReadKey();
            int typeId;

            Int32.TryParse(operation.KeyChar.ToString(), out typeId);
            Console.WriteLine("Podaj nazqwe pliku:");
            var  name   = Console.ReadLine();
            var  lastId = _itemService.GetLastId();
            Item item   = new Item(lastId + 1, name, typeId);

            _itemService.AddItem(item);
            return(item.Id);
        }
예제 #5
0
        public int AddNewItem(CategoryManager _categoryManager)
        {
            if (_categoryService.Items.Count <= 0)
            {
                Console.Clear();
                Console.WriteLine("Category list is empty. First please add at least one category.");
                return(0);
            }
            else
            {
                double kcal, fat, protein, carb;
                Console.WriteLine("Please type name of product...");
                string name = Console.ReadLine();
                do
                {
                    Console.WriteLine("Please type product kcal/100g...");
                }while (double.TryParse(Console.ReadLine(), out kcal) != true);
                do
                {
                    Console.WriteLine("Please type product fat/100g...");
                }while (double.TryParse(Console.ReadLine(), out fat) != true);
                do
                {
                    Console.WriteLine("Please type product protein/100g...");
                }while (double.TryParse(Console.ReadLine(), out protein) != true);
                do
                {
                    Console.WriteLine("Please type product carb/100g...");
                }while (double.TryParse(Console.ReadLine(), out carb) != true);

                var  choosenCategory = _categoryManager.GetCategory();
                int  id         = _itemService.GetLastId();
                Item itemHolder = new Item(id + 1, name, kcal, fat, protein, carb, choosenCategory.Id);
                _itemService.AddItem(itemHolder);

                return(itemHolder.Id);
            }
        }
예제 #6
0
 public int AddItem(Item item)
 {
     _itemService.AddItem(item);
     return(item.Id);
 }
예제 #7
0
        public async Task <IActionResult> AddItem([NotEmptyGuid] Guid id, [BindRequired, FromBody] ProductDTO product)
        {
            await _service.AddItem(id, product);

            return(Ok());
        }