Exemplo n.º 1
0
        public IActionResult Delete(Personal personal)
        {
            var result = _personalService.Delete(personal);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public IActionResult DeletePersonal(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }

            var user     = _userService.GetUserByUsername(User.Identity.Name);
            var personal = _personalService.GetById((int)id);

            if (personal == null)
            {
                return(NotFound());
            }

            if (user.Id == personal.ManagerId)
            {
                _personalService.Delete((int)id);
                return(RedirectToAction("Index", "Home"));
            }

            return(RedirectToAction("Detail", "Personal", personal.Id));
        }
Exemplo n.º 3
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (Convert.ToInt32(dgwTakip.CurrentRow.Cells[4].Value) == 1)
                {
                    try
                    {
                        _personalService.Delete(new Personal()
                        {
                            PersonalId = Convert.ToInt32(dgwTakip.CurrentRow.Cells[0].Value)
                        });
                        MessageBox.Show("Personal siliniyor");
                    }
                    catch
                    {
                        MessageBox.Show("Silmek istediğin personelin üzerine tıkladığından emin ol");
                    }

                    try
                    {
                        _kisiService.Delete(new Kisi()
                        {
                            KisiId = Convert.ToInt64(dgwTakip.CurrentRow.Cells[3].Value)
                        });
                        MessageBox.Show("Personal silindi");
                    }
                    catch
                    {
                        MessageBox.Show("Zimmetli Eşyası olan personeli silemezsin");
                    }
                }

                if (Convert.ToInt32(dgwTakip.CurrentRow.Cells[5].Value) == 1 || Convert.ToInt32(dgwTakip.CurrentRow.Cells[5].Value) == 0)
                {
                    try
                    {
                        _urunService.Delete(new Urun()
                        {
                            UrunId = Convert.ToInt32(dgwTakip.CurrentRow.Cells[1].Value)
                        });

                        MessageBox.Show("Ürün siliniyor");
                    }
                    catch
                    {
                        MessageBox.Show("Kullanılan Ürünü silemezsin");
                    }

                    try
                    {
                        _markaService.Delete(new Marka()
                        {
                            MarkaId = Convert.ToInt32(dgwTakip.CurrentRow.Cells[1].Value)
                        });
                        MessageBox.Show("Ürün silindi");
                    }
                    catch
                    {
                        MessageBox.Show("Kullanılan markayı silemezsin");
                    }
                }

                if (Convert.ToInt32(dgwTakip.CurrentRow.Cells[2].Value) == 1 ||
                    Convert.ToInt32(dgwTakip.CurrentRow.Cells[2].Value) == 0)
                {
                    try
                    {
                        _zimmetService.Delete(new Zimmet()
                        {
                            ZimmetId = Convert.ToInt32(dgwTakip.CurrentRow.Cells[0].Value)
                        });
                        MessageBox.Show("Zimmet Silindi");
                    }
                    catch
                    {
                        MessageBox.Show("TestZimmet");
                    }
                }
            }
            catch
            {
            }
        }