public string AjaxDeleteCalisan() { // 0 - silme işlemi başarısız oldu // 1 - Silme işlemi başarılı oldu string donenkod = "0"; int ID = Convert.ToInt32(Request.Form["id"]); Calisan calisan = CalisanRepository.Find(ID); int YoneticiMi = CalisanRepository.Count(x => x.YoneticiBilgisiId == calisan.Id); if (YoneticiMi > 0) { return(donenkod); } else { try { CalisanRepository.Delete(ID); CalisanRepository.Save(); donenkod = "1"; } catch (Exception ex) { } return(donenkod); } }
public ActionResult Edit(Calisan model) { int ID = Convert.ToInt32(RouteData.Values["id"]); int DepartmanId = Convert.ToInt32(Request["DepartmanID"]); Calisan calisan = CalisanRepository.FirstOrDefault(x => x.Id == ID); calisan.Ad = Request["Ad"].ToString(); calisan.Soyad = Request["Soyad"].ToString(); calisan.Telefon = model.Telefon; calisan.DepartmanId = DepartmanId; calisan.YoneticiBilgisiId = model.YoneticiBilgisiId; try { CalisanRepository.Update(calisan); CalisanRepository.Save(); return(RedirectToAction("Listele")); } catch (Exception) { return(View(model)); } }
public ActionResult Ekle(Calisan model) { Calisan calisan = new Calisan(); calisan.Ad = Request["Ad"].ToString(); calisan.Soyad = Request["Soyad"].ToString(); calisan.Telefon = Request["Telefon"].ToString(); calisan.DepartmanId = Convert.ToInt32(Request["DepartmanID"]); //calisan.YoneticiBilgisiId= CalisanRepository().Find; if (Request["Yoneticiler"] != null) { calisan.YoneticiBilgisiId = Convert.ToInt32(Request["Yoneticiler"]); } try { CalisanRepository.Add(calisan); CalisanRepository.Save(); return(RedirectToAction("Listele")); } catch (Exception) { return(View(model)); } }