Ejemplo n.º 1
0
        private IEnumerable <CreateCarImageDto> Resolve(ManageCarViewModel vm)
        {
            var retVal = new List <CreateCarImageDto>();

            var main = new CreateCarImageDto
            {
                Bytes     = GetBytes(vm.MainImage),
                Extension = GetExtension(vm.MainImage),
                IsMain    = true
            };

            retVal.Add(main);

            vm.Images.ToList().ForEach(x =>
            {
                var img = new CreateCarImageDto
                {
                    Bytes     = GetBytes(x),
                    Extension = GetExtension(x)
                };
                retVal.Add(img);
            });

            return(retVal);
        }
Ejemplo n.º 2
0
        private void buttonUpdateCar_Click(object sender, EventArgs e)
        {
            if (!Utils.FormIsOpen("AddEditCar") && dataGridViewManageCars.SelectedRows.Count > 0)
            {
                // get the values of the selected row for pre-populating edit form
                DataGridViewRow selectedRow = dataGridViewManageCars.SelectedRows[0];

                int    carID        = (int)selectedRow.Cells["ID"].Value;
                string make         = selectedRow.Cells["Make"].Value.ToString();
                string model        = selectedRow.Cells["Model"].Value.ToString();
                string year         = selectedRow.Cells["Year"].Value.ToString();
                string vin          = selectedRow.Cells["VIN"].Value.ToString();
                string licensePlate = selectedRow.Cells["LicensePlate"].Value.ToString();

                var manageCarVM = new ManageCarViewModel
                {
                    ID           = carID,
                    Make         = make,
                    Model        = model,
                    Year         = year,
                    VIN          = vin,
                    LicensePlate = licensePlate,
                };

                AddEditCar addEditCarForm = new AddEditCar(isEdit: true, manageCarVM: manageCarVM, manageCarsForm: this);
                addEditCarForm.MdiParent = this.MdiParent;
                addEditCarForm.Show();
            }
            else
            {
                MessageBox.Show("Info: An instance of the Add/Edit Car Window is open.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 3
0
        public AddEditCar(bool isEdit, ManageCarViewModel manageCarVM = null, ManageCars manageCarsForm = null)
        {
            this.isEdit         = isEdit;
            this.manageCarsForm = manageCarsForm;

            InitializeComponent();

            if (this.isEdit)
            {
                addEditCarTitle.Text  = "Edit Car";
                this.Text             = "Edit Car";
                buttonAddEditCar.Text = "Edit Car";

                textBoxMake.Text    = manageCarVM.Make;
                textBoxModel.Text   = manageCarVM.Model;
                textBoxYear.Text    = manageCarVM.Year;
                textBoxVIN.Text     = manageCarVM.VIN;
                textBoxLicense.Text = manageCarVM.LicensePlate;

                this.manageCarVM = manageCarVM;
            }
            else
            {
                addEditCarTitle.Text  = "Add Car";
                this.Text             = "Add Car";
                buttonAddEditCar.Text = "Add Car";
            }
        }