public IActionResult Index(ManagerProductViewModel vm) { if (vm.EventCommand == "list") { vm.AllProductsCount = _ProductData.GetAll().Count(); vm.IsListAreaVisible = true; vm.IsSearchAreaVisible = true; vm.IsAddPhoneFormAreaVisible = false; vm.IsAddLaptopFormAreaVisible = false; vm.Products = _ProductData.GetPorductsofNum(vm.SkipDisplayList, vm.TakeDisplayList); } else if (vm.EventCommand == "search") { vm.IsListAreaVisible = true; vm.IsSearchAreaVisible = true; vm.IsAddPhoneFormAreaVisible = false; vm.IsAddLaptopFormAreaVisible = false; vm.Products = _ProductData.SearchByTitle(vm.ProductSearchName); vm.AllProductsCount = vm.Products.Count(); } else if (vm.EventCommand == "addPhone") { vm.IsListAreaVisible = false; vm.IsSearchAreaVisible = false; vm.IsAddPhoneFormAreaVisible = true; } else if (vm.EventCommand == "addLaptop") { vm.IsListAreaVisible = false; vm.IsSearchAreaVisible = false; vm.IsAddPhoneFormAreaVisible = false; vm.IsAddLaptopFormAreaVisible = true; vm.Products = _ProductData.GetAll(); } else if (vm.EventCommand.Contains("editPhone")) { string productID = vm.EventCommand.Replace("editPhone/", ""); vm.Phone = (Phone)_ProductData.FindProductById(int.Parse(productID)); vm.IsListAreaVisible = false; vm.IsSearchAreaVisible = false; vm.IsAddPhoneFormAreaVisible = false; vm.IsEditLaptopFormAreaVisible = false; vm.IsEditPhoneFormAreaVisible = true; } else if (vm.EventCommand.Contains("editLaptop")) { string productID = vm.EventCommand.Replace("editLaptop/", ""); vm.Laptop = (Laptop)_ProductData.FindProductById(int.Parse(productID)); vm.IsListAreaVisible = false; vm.IsSearchAreaVisible = false; vm.IsAddPhoneFormAreaVisible = false; vm.IsAddLaptopFormAreaVisible = false; vm.IsEditLaptopFormAreaVisible = true; } vm.SubDepartments = _DepartmentData.GetAllSubDepartments(); return(View(vm)); }