示例#1
0
        public IActionResult DeleteConfirmed(int id)
        {
            var vehicle = VehicleManager.Find(v => v.Id == id);

            VehicleManager.Delete(vehicle);
            return(RedirectToAction("Index"));
        }
示例#2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvwVehicles.SelectedItems != null && lvwVehicles.SelectedItems.Count != 0)
                {
                    if (!IsList)
                    {
                        if (objUIRights.DeleteRight)
                        {
                            DialogResult dr = new DialogResult();
                            dr = MessageBox.Show("Do You Really Want to Delete Record ?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                            if (dr == DialogResult.Yes)
                            {
                                Vehicle objVehicle = new Vehicle();
                                objVehicle = VehicleManager.GetItem(Convert.ToInt32(lvwVehicles.SelectedItems[0].Name));
                                VehicleManager.Delete(objVehicle);
                                lvwVehicles.Items.Remove(lvwVehicles.SelectedItems[0]);
                            }
                        }
                        else
                        {
                            throw new Exception("Not Authorised.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#3
0
        public static void DeleteCarTest()
        {
            VehicleManager carManager = new VehicleManager(new EfVehicleDal());
            var            result     = carManager.Delete(new Vehicle {
                CarId = 8, BrandId = 5, ColorId = 3, VehicleName = "BMW 316i", ModelYear = 2019, DailyPrice = 400, Description = "otomatik"
            });

            if (result.Success == true)
            {
                Console.WriteLine(result.Message);
            }
            else
            {
                Console.WriteLine(result.Message);
            }
        }