public async Task <IActionResult> PutUsers(int id, Users users)
        {
            if (id != users.Id)
            {
                return(BadRequest());
            }

            _context.Entry(users).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UsersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        /// <summary>
        /// Adds or updates a customer.
        /// </summary>
        /// <param name="obj"></param>
        private async void ExecSaveCustomerAsync(object obj)
        {
            switch (App.DataSource)
            {
            case ConnectionResource.LOCALAPI:
                WebServiceManager <Customer> webServiceManager = new WebServiceManager <Customer>();
                if (Customer.Id == 0)     // Saving new customer
                {
                    await webServiceManager.PostAsync(Customer);
                }
                else     // Saving updated customer
                {
                    await webServiceManager.PutAsync(Customer);
                }
                break;

            case ConnectionResource.LOCALMYSQL:
                using (var ctx = new MysqlDbContext(ConnectionResource.LOCALMYSQL))
                {
                    if (Customer.Id == 0)     // Saving new customer
                    {
                        ctx.DbSetCustomers.Add(Customer);
                        await ctx.SaveChangesAsync();
                    }
                    else     // Saving updated customer
                    {
                        ctx.Entry(Customer).State         = EntityState.Modified;
                        ctx.Entry(Customer.Address).State = EntityState.Modified;
                        await ctx.SaveChangesAsync();
                    }
                }
                break;

            default:
                break;
            }

            CustomerView.NavigationService.Navigate(new CustomerListView());
        }
        /// <summary>
        /// Processes the payment.
        /// Stock of products decreased, customer gets charged.
        /// </summary>
        /// <param name="obj"></param>
        private async void ExecProceedToPaymentAsync(object obj)
        {
            Cart.Customer.Money -= Cart.Total;

            switch (App.DataSource)
            {
            case ConnectionResource.LOCALAPI:
                await new WebServiceManager <Cart>().PostAsync(Cart);
                break;

            case ConnectionResource.LOCALMYSQL:
                using (var ctx = new MysqlDbContext(ConnectionResource.LOCALMYSQL))
                {
                    ctx.Entry(Cart.Customer).State = EntityState.Modified;
                    foreach (var item in Cart.Items)
                    {
                        ctx.Entry(item.Product).State = EntityState.Modified;
                    }
                    ctx.DbSetCarts.Add(Cart);
                    await ctx.SaveChangesAsync();
                }
                break;

            default:
                break;
            }

            foreach (var item in Cart.Items)
            {
                if (item.Product.Stock > 0)
                {
                    if (item.Product is CPU)
                    {
                        CPUs.Add((CPU)item.Product);
                    }
                    else if (item.Product is GPU)
                    {
                        GPUs.Add((GPU)item.Product);
                    }
                    else if (item.Product is Motherboard)
                    {
                        Motherboards.Add((Motherboard)item.Product);
                    }
                    else if (item.Product is Memory)
                    {
                        Rams.Add((Memory)item.Product);
                    }
                    else if (item.Product is Storage)
                    {
                        StorageComponents.Add((Storage)item.Product);
                    }
                    else if (item.Product is PSU)
                    {
                        PSUs.Add((PSU)item.Product);
                    }
                    else // Case
                    {
                        Cases.Add((Case)item.Product);
                    }
                }
            }
            Cart.Items.Clear();
            Cart.Total = 0;
        }
        /// <summary>
        /// Adds or updates a product.
        /// </summary>
        /// <param name="obj"></param>
        private async void ExecSaveProductAsync(object obj)
        {
            switch (App.DataSource)
            {
            case ConnectionResource.LOCALAPI:
                if (Product.Id == 0)     // Saving new product
                {
                    if (Product is CPU)
                    {
                        await new WebServiceManager <CPU>().PostAsync((CPU)Product);
                    }
                    else if (Product is GPU)
                    {
                        await new WebServiceManager <GPU>().PostAsync((GPU)Product);
                    }
                    else if (Product is Motherboard)
                    {
                        await new WebServiceManager <Motherboard>().PostAsync((Motherboard)Product);
                    }
                    else if (Product is Memory)
                    {
                        await new WebServiceManager <Memory>().PostAsync((Memory)Product);
                    }
                    else if (Product is Storage)
                    {
                        await new WebServiceManager <Storage>().PostAsync((Storage)Product);
                    }
                    else if (Product is PSU)
                    {
                        await new WebServiceManager <PSU>().PostAsync((PSU)Product);
                    }
                    else     // Case
                    {
                        await new WebServiceManager <Case>().PostAsync((Case)Product);
                    }
                }
                else     // Saving updated product
                {
                    if (Product is CPU)
                    {
                        await new WebServiceManager <CPU>().PutAsync((CPU)Product);
                    }
                    else if (Product is GPU)
                    {
                        await new WebServiceManager <GPU>().PutAsync((GPU)Product);
                    }
                    else if (Product is Motherboard)
                    {
                        await new WebServiceManager <Motherboard>().PutAsync((Motherboard)Product);
                    }
                    else if (Product is Memory)
                    {
                        await new WebServiceManager <Memory>().PutAsync((Memory)Product);
                    }
                    else if (Product is Storage)
                    {
                        await new WebServiceManager <Storage>().PutAsync((Storage)Product);
                    }
                    else if (Product is PSU)
                    {
                        await new WebServiceManager <PSU>().PutAsync((PSU)Product);
                    }
                    else     // Case
                    {
                        await new WebServiceManager <Case>().PutAsync((Case)Product);
                    }
                }
                break;

            case ConnectionResource.LOCALMYSQL:
                using (var ctx = new MysqlDbContext(App.DataSource))
                {
                    if (Product.Id == 0)     // Saving new product
                    {
                        if (Product is CPU)
                        {
                            ctx.DbSetCPUs.Add((CPU)Product);
                        }
                        else if (Product is GPU)
                        {
                            ctx.DbSetGPUs.Add((GPU)Product);
                        }
                        else if (Product is Motherboard)
                        {
                            ctx.DbSetMotherboards.Add((Motherboard)Product);
                        }
                        else if (Product is Memory)
                        {
                            ctx.DbSetMemories.Add((Memory)Product);
                        }
                        else if (Product is Storage)
                        {
                            ctx.DbSetStorages.Add((Storage)Product);
                        }
                        else if (Product is PSU)
                        {
                            ctx.DbSetPSUs.Add((PSU)Product);
                        }
                        else     // Case
                        {
                            ctx.DbSetCases.Add((Case)Product);
                        }
                        await ctx.SaveChangesAsync();
                    }
                    else     // Saving updated product
                    {
                        ctx.Entry(Product).State = EntityState.Modified;
                        await ctx.SaveChangesAsync();
                    }
                }
                break;

            default:
                break;
            }

            string activeTabName = (string)Utility.FindParent <StackPanel>((Button)ProductView.ProductUserControl.SaveProductBtn).Tag;

            ProductView.NavigationService.Navigate(new ProductListView(activeTabName));
        }