public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                throw new Exception("Upps! Yanlış giden birşeyler var.");
            }
            AltDepartman altDepartman = _altDepartmanService.GetById((int)id);

            ViewBag.Departman_No = new SelectList(_departmanService.GetAllDepartmanlar(), "Departman_No", "Adi", altDepartman.Departman_No);
            if (altDepartman == null)
            {
                return(HttpNotFound());
            }
            return(View(altDepartman));
        }
 public ActionResult Edit(AltDepartman altDepartman)
 {
     if (permissionUser.SysAdmin == false)
     {
         throw new Exception("Yetkisiz Erişim!");
     }
     else
     {
         if (ModelState.IsValid)
         {
             var altdepartman = _altDepartmanService.GetById(altDepartman.Alt_Departman_No);
             if (altdepartman != null)
             {
                 _altDepartmanService.UpdateAltDepartman(altDepartman);
                 return(RedirectToAction("Index"));
             }
         }
         return(View(altDepartman));
     }
 }
 public ActionResult Delete(int id = -1)
 {
     if (permissionUser.SysAdmin == false)
     {
         throw new Exception("Yetkisiz Erişim!");
     }
     else
     {
         if (id != -1)
         {
             AltDepartman altDepartman = _altDepartmanService.GetById(id);
             if (altDepartman != null)
             {
                 _altDepartmanService.DeleteAltDepartman(altDepartman);
                 return(RedirectToAction("Index"));
             }
         }
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult Create(AltDepartman AltDepartman)
        {
            if (permissionUser.SysAdmin == false)
            {
                throw new Exception("Yetkisiz Erişim!");
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (AltDepartman.Adi != null && AltDepartman.Departman_No != null)
                    {
                        var ID = _altDepartmanService.GetAllAltDepartman().Count;
                        if (ID == 0)
                        {
                            _altDepartmanService.DeleteAll();
                        }

                        _altDepartmanService.AddAltDepartman(AltDepartman);

                        foreach (var dbSysAdmin in _dBUsersService.GetAllDBUsers(x => x.SysAdmin == true))
                        {
                            var dbAltDepartman = new DBUsersAltDepartman
                            {
                                Kullanici_Adi    = dbSysAdmin.Kullanici_Adi,
                                Departman_No     = AltDepartman.Departman_No,
                                Alt_Departman_No = AltDepartman.Alt_Departman_No
                            };
                            _dBUsersAltDepartmanService.AddDBUsersAltDepartman(dbAltDepartman);
                        }


                        return(RedirectToAction("Index"));
                    }
                    throw new Exception("Yanlış yada eksik karakter girdiniz.");
                }
                return(RedirectToAction("Index"));
            }
        }
 public AltDepartman UpdateAltDepartman(AltDepartman altDepartman)
 {
     return(_altDepartmanDal.Update(altDepartman));
 }
 public void DeleteAltDepartman(AltDepartman altDepartman)
 {
     _altDepartmanDal.Delete(altDepartman);
 }
 public AltDepartman AddAltDepartman(AltDepartman altDepartman)
 {
     return(_altDepartmanDal.Add(altDepartman));
 }