private async void dgvProducts_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                var productId  = dgvProducts.Rows[e.RowIndex].Cells["ProductId"].Value;
                var action     = dgvProducts.Columns[e.ColumnIndex].Name;
                var productApi = new APIService("products");
                var product    = await productApi.GetById <Model.Product>(productId);

                CustomMessageBox messageBox = new CustomMessageBox();
                if (action == "Edit")
                {
                    AddEditProductForm form = new AddEditProductForm(_menuForm, this, _cinemaName, _cinemaId, int.Parse(productId.ToString()))
                    {
                    };
                    _helper.ShowForm(form, 15);
                }
                else if (action == "Delete")
                {
                    DialogResult dialogResult = MessageBox.Show($"Are you sure you want to delete '{product.Name}' for {product.Price} in '{_cinemaName}'?", "Delete product", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        Helper helper = new Helper();
                        await productApi.Delete <Model.Product>(productId);

                        helper.CloseForm(this, 15);
                        CinemasProductsForm form = new CinemasProductsForm(_menuForm, _cinemaId, _cinemaName);
                        helper.ShowForm(form, 15);
                        messageBox.Show("Product deleted successfully", "success");
                    }
                }
            }
        }
 public AddEditProductForm(MenuForm menuForm, CinemasProductsForm cinemasProductsForm, string cinemaName, int cinemaId, int?productId = null)
 {
     InitializeComponent();
     _menuForm            = menuForm;
     _cinemaId            = cinemaId;
     _productId           = productId;
     _cinemasProductsForm = cinemasProductsForm;
     _cinemaName          = cinemaName;
     this.StartPosition   = FormStartPosition.Manual;
     this.Location        = new Point(Screen.PrimaryScreen.Bounds.Width - 20 - this.Width, Screen.PrimaryScreen.Bounds.Height - this.Height - saveBtn.Height - 20);
 }
        private async void saveBtn_Click(object sender, EventArgs e)
        {
            var messageBox = new CustomMessageBox();

            if (string.IsNullOrWhiteSpace(ProductName.Text) || ProductName.Text.Length < 3)
            {
                messageBox.Show("The name field requires 3 letters!", "error");
                return;
            }

            if (!_helper.ValidateDecimalString(ProductPrice.Text, 1, 150))
            {
                messageBox.Show("Enter a valid price (1-150)!", "error");
                return;
            }

            Model.Requests.InsertProductRequest product = new Model.Requests.InsertProductRequest()
            {
                Name     = ProductName.Text,
                Price    = decimal.Parse(ProductPrice.Text),
                CinemaId = _cinemaId
            };

            if (_productId.HasValue)
            {
                await _apiService.Update <Model.Product>(_productId, product);

                messageBox.Show("Product updated succesfully", "Success");
            }
            else
            {
                await _apiService.Insert <Model.Product>(product);

                messageBox.Show("Product added succesfully", "Success");
            }

            CinemasProductsForm form = new CinemasProductsForm(_menuForm, _cinemaId, _cinemaName);

            _cinemasProductsForm.Close();
            _helper.CloseForm(this, 15);
            _helper.ShowForm(form, 15);
        }